@smartcloud/datastore
v0.0.8
Published
Google Datastore Module of SmartCloud Utility Library for Node.js
Downloads
2
Keywords
Readme
@smartcloud/datastore
Google Cloud Datastore Module of SmartCloud Utility Library for Node.js
Methods are exposed through Javascript object called CloudDatastore
npm installation
$ npm install --save @smartcloud/datastore
Class
The module has core class named "CloudDatastore". To initialize an CloudDatastore object, pass the follow parameters.
* aggregateType - (required) specify aggregateType which is also used as target EntityKind in Google cloud datastore.
* maxRetries - (optional) specify maximum number of times that process can retry in case of failure. If not specified, default will be 10.
* indexColumns - (optional) specify array of property names which need to be indexed.
Sample usage
const SmartCloudDatastore = require('@smartcloud/datastore');
var client = new SmartCloudDatastore.CloudDatastore({
aggregateType: 'Foo',
indexColumns: ['foo1', 'foo2']
});
Methods
datastoreKey(keyOptions) method - Return Google datastore key based on keyOptions given. For keyOptions structure, follow Google datastore key.
datastore() method - Return current datastore instance associated with current CloudDatastore instance
convertObjectToUnindexedData() method - Unindex all the properties of the object targeted to persist in Google datastore excluding properties specified through indexColumns during CloudDatastore object initialization
saveRecord(entity, path) method - Save specified entity into Google datastore.
queryDatastore(query) method - Run Google datastore query
loadFromDatastore(key) method - Get object from Google datastore
deleteFromDatastore(key) method - Delete object from Google datastore
saveRecords(entities) method - Save multiple entities into Google datastore