sebelga / gstore-node

Google Datastore Entities Modeling for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MyModel.delete() doesn't work with string ids

theArina opened this issue · comments

commented

Hi,

Thanks for reporting. This is strange, I will check if there were a regression. Cheers 👍

Should I move this issue to the gstore-node repository?

commented

Okay

Just to make sure, you are saying that it does not work with an Array of string ids, is that correct?

commented

I'm pretty sure that it's both, single id and array

Hello,
I finally got a chance to look at it. Indeed, MyModel.get() MyModel.update() and MyModel.delete() don't work with string id. You need to parse it to integer first

const id = '1234';
MyModel.delete(+id);

This is because Datastore treats a string as "name" in the entity key and not "id". I plan on updating the gstore API (next major version) for those methods where you would have to specify if you are providing a Key id or a Key name. Probably something like this:

const id = '1234';
MyModel.delete({ id });

const name = 'john@snow.com';
MyModel.delete({ name });

Cheers 👍

I will close this issue as it will be solved with this issue: #212