Summary:
- Returns a promise so it's predictable and easier to work with
- Destructuring of entities
- Destructuring of keys
- Destructuring of endCursor (for Pagination support)
- Support for SELECT, FILTER and LIMIT
- Support for ORDER, as replaced with ASCEND and DESCEND for readability
- Queries are chainable of course
const Reader = new DataStoreReader('Inventory');
Reader
.FILTER('current_amount', '=', '0')
.LIMIT(5)
.RUNQUERY()
.then(()=>{
// do your magic
})
.catch(()=>{
// do your magic
});
Files:
- index.js - DataStoreReader setup & class itself
- test.js - Test example
Notes
- Docs is here: https://cloud.google.com/datastore/docs/concepts/queries
- Type checks not included, but easy to add.
- Support for special query types not included, but easy to add: https://cloud.google.com/datastore/docs/concepts/queries#special_query_types
Improved @ https://www.npmjs.com/package/google-cloud-datastore-toolkit