sebelga / gstore-node

Google Datastore Entities Modeling for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactor (and simplify) Model methods parameters

sebelga opened this issue · comments

We will use this next major version bump to update the API of the Model APIs. Indeed having to pass a bunch of null (or undefined) value to set an option

// current api
BlogPost.get(123, null, null, null, { dataloader });

I will simplify with only 2 (max 3) parameters

// Datastore makes a difference between an "ID" (integer) and a "name" (string) for a Key.
// The new API will require to specify if we are providing an ID or Name
BlogPost.get({ id:  123 }, { dataloader }); 

For Model.update() it will be 3

BlogPost.update(
  { id: 123 }, // id
  { ...data }, // data
  { ancestors: ['SomeParent', 'ParentName'], replace: true } // any additional (optional) option
);

Todo

  • key() (#214)
  • get() (#214)
  • mget()
  • delete()
  • mdelete()
  • update()

Closing this issue as I won't be able to continue the work on it.