gstore has a global method "save" that is an alias of the original @google-cloud/datastore save() method, with the exception that you can pass it an Entity instance or an Array of entities instances and this method will first convert the instances to the correct Datastore format before saving.
This method accepts the following arguments:
/* {entity instance}. -- Can also be an Array of entities */
/* {Transaction} -- optional. The transaction currently in progress */
/* {object} -- optional. An optional object of options */
Note: The entities can be of any kind. You can concat several arrays of queries from different Models and then save them all at once with this method.


The options object has 2 properties:
  • validate (default false)
  • method (default "upsert"}
By default, validation is turned off as adds some overhead for large batch. If you need validation, just turn set validate to true.
The method option is the Datastore save() method. Valid values are: "insert", "update" or "upsert".
const query = BlogModel.query().limit(20);{ format: "ENTITY" })
.then((result) => {
const entities = result[0].entities;
// entities are gstore instances, you can manipulate them
// and then save them by calling: => {
* With options
*/, undefined, { validate: true, method: 'insert' })
.then(() => { ... });
* From inside a transaction
const transaction = gstore.transaction(); => {
const query = BlogModel.query(null, transaction).limit(20);
.then((response) => {
const entities = response[0].entities;
// Call the global save method passing the transaction., transaction).then( ... );