gcloud-keystore
Use a gcloud-node dataset as a Key/Value store.
Install
$ npm install --save gcloud-keystore
Example
var keystore = ;var gcloud = /*...*/;var dataset = gclouddatastore; var keystore = ; // Set an item.keystore; // Get an item.keystore; // Delete an item.keystore;
How
Google Cloud Datastore is a managed, NoSQL, schemaless database for storing non-relational data. Datastore entities are complex objects. However, we can wrap this complexity to mimic a simple key/value store by storing a numeric or string "key" as the id of an entity.
The example below shows the complexity that is hidden with gcloud-keystore
.
gcloud-node
:
With var key = dataset; dataset; dataset; dataset;
gcloud-node
+ gcloud-keystore
:
With var keystore = dataset; keystore; keystore; keystore;
API
keystore(dataset)
dataset
A gcloud-node Datastore Dataset instance.
keystore#delete(key, callback)
key
Type: String|Number
callback
Type: Function
Executed with the same signature as Dataset#delete.
keystore#get(key, callback)
key
Type: String|Number
callback
Type: Function
Executed with (err
, value
)
keystore#set(key, value, callback)
key
Type: String|Number
value
Type: *
callback
Type: Function
Executed with the same signature as Dataset#save.
Credit
Concept originally created by Patrick Costello: https://github.com/GoogleCloudPlatform/gcloud-node/issues/256#issuecomment-58962323.
License
MIT © Stephen Sawchuk