In order to get a gstore instance, import the module and then call it and provide an optional configuration object. The gstore instances are cached so you can do this in multiple places of your application, the same instance will always be returned.
Optionally you can provide a configuration object when creating the instance with the following properties:
namespace (string)
String (default: "gstore-node")
This allows you to create multiple instances of gstore. The following example will create 2 instances of gstore that can connect to 2 different Datastore client instances (see below).
constGstoreNode=require('gstore-node');constgstoreDefaultInstance=GstoreNode();constgstoreInstance1=GstoreNode({namespace:'instance-1'});constgstoreInstance2=GstoreNode({namespace:'instance-2'});// anywhere in your application...constgstoreDefaultInstance=require('gstore-node')();// Get the default instance// orconstgstoreInstance1=require('gstore-node')({namespace:'instance-1'});// Get other instance
errorOnEntityNotFound
Boolean (default: true)
By default if you fetch an entity by Key and the entity is not found in the Datastore, gstore will throw an "ERR_ENTITY_NOT_FOUND" error. If you prefer to have null returned when an entity is not found, set errorOnEntityNotFound to false.