oakdatastore

0.4.0 • Public • Published

oakdatastore

A partial gcloud-node (google cloud) datastore wrapper with bluebird promises in functional style. Only does minimally what we need, no guarantees expressed or implied. Pull Requests for expanded functions/features are welcome.

See tests for usage.

Tested with node v4 LTS

API Reference

oakdatastore module.

oakdatastore.getDataStore(options) ⇒ Object

Make a datastore object from gcloud-node options

Kind: static method of oakdatastore
Returns: Object - gcloud-node datastore object

Param Type Description
options Object gcloud-node options

oakdatastore.makeKey(datastore, path_list) ⇒ Object

Make a datastore key

Kind: static method of oakdatastore
Returns: Object - datastore key

Param Type Description
datastore Object gcloud-node datastore object
path_list Array the datastore path in array form: ['root', 'sub1', 'sub2', 'id']

oakdatastore.save_P(datastore, entities, method,) ⇒ Promise

Save multiple objects to datastore using the same method. nb if you "insert" 100 entities but 1 of them already exists, none of the entities will be written

Kind: static method of oakdatastore
Returns: Promise - resolving to apiResponse

Param Type Description
datastore Object gcloud-node datastore object
entities Array.<Object> in form [{key, data}, ..]
method, string one of: insert, update, upsert (default: insert)

oakdatastore.get_P(datastore, keys) ⇒ Promise

Get multiple objects from datastore

Kind: static method of oakdatastore
Returns: Promise - resolving to apiResponse

Param Type Description
datastore Object gcloud-node datastore object
keys string | Array.<string>

oakdatastore.delete_P(datastore, keys) ⇒ Promise

Delete multiple objects from datastore

Kind: static method of oakdatastore
Returns: Promise - resolving to apiResponse

Param Type Description
datastore Object gcloud-node datastore object
keys string | Array.<string>

oakdatastore.deleteNamespace_P(datastore, namespace) ⇒ Promise

deletes all entities in a namespace

Kind: static method of oakdatastore
Returns: Promise - warning: this may take a long time to complete

Param Type Description
datastore Object gcloud-node datastore object
namespace string to wipe

oakdatastore.workOnQuery_P(datastore, gcloud-node, worker_P) ⇒ Promise

A helper function to process a query - warning: this may take a long time to complete

Kind: static method of oakdatastore
Returns: Promise - resolving to the final apiResponse

Param Type Description
datastore Object gcloud-node datastore object
gcloud-node Object query object, as returned by createQuery()
worker_P function callback worker function which takes args: (datastore, entities) and must return a promise - will be called serially for larger datasets

oakdatastore.createQuery(datastore, kind, [namespace], [auto_paginate]) ⇒ Object

Create datastore query

Kind: static method of oakdatastore
Returns: Object - gcloud-node datastore/query object

Param Type Description
datastore Object gcloud-node datastore object
kind string
[namespace] string optional namespace
[auto_paginate] bool set false to manually page through results (default: true)

oakdatastore.runQuery(handle, query, [callback])

Run gcloud-node datastore query, a functional-style helper

Kind: static method of oakdatastore

Param Type Description
handle Object gcloud-node datastore or transaction object
query Object created by createQuery()
[callback] function optional callback to run with query results in form function(err, entities, nextQuery, apiResponse)

oakdatastore.makeEntity(key, data) ⇒ Object

Make entity helper

Kind: static method of oakdatastore
Returns: Object - entity

Param Type Description
key Object gcloud-node datastore key
data Object to be stored in entity value

Update Docs

./doc/generate

Development

Either use the atom babel package, or use gulp and babel to transpile from src to build.

Test

npm test or npm run testwatch or npm test -- watch

Package Sidebar

Install

npm i oakdatastore

Weekly Downloads

2

Version

0.4.0

License

MIT

Last publish

Collaborators

  • oakleon