@google-cloud Query

gstore is built on top of @google-cloud/datastore so you can execute any query from the Google library.

  1. Create a query object const query = MyModel.query(namespace /*optional*/, transaction /*optional*/)

  2. Chain the operators to build the query. query.filter(...).order(...).start(...)

  3. Call query.run() to execute the query. query.run([options]).then( ... )

Create the query

const query = MyModel.query(
    /* {string}. -- optional. A namespace to execute the query */
    <namespace>,
    /* {object} -- optional. A transaction to execute the query from */
    <transaction>
);

Chain query operators

Refer to @google-cloud/datastore for the list of methods and operators available.

query.filter(...).order(...).groupBy(...).start(...);

Run the query

To execute the query call query.run(options)

@Returns: the response is an object with 2 properties:

  • entities

  • nextPageCursor // only present if there are More Results to fetch

Example:

Last updated

Was this helpful?