0.4.0 • Published 8 years ago

oakdatastore v0.4.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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

ParamTypeDescription
optionsObjectgcloud-node options

oakdatastore.makeKey(datastore, path_list) ⇒ Object

Make a datastore key

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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
path_listArraythe 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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
entitiesArray.<Object>in form {key, data}, ..
method,stringone 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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
keysstring | Array.<string>

oakdatastore.delete_P(datastore, keys) ⇒ Promise

Delete multiple objects from datastore

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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
keysstring | 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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
namespacestringto 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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
gcloud-nodeObjectquery object, as returned by createQuery()
worker_Pfunctioncallback 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

ParamTypeDescription
datastoreObjectgcloud-node datastore object
kindstring
namespacestringoptional namespace
auto_paginateboolset 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

ParamTypeDescription
handleObjectgcloud-node datastore or transaction object
queryObjectcreated by createQuery()
callbackfunctionoptional 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

ParamTypeDescription
keyObjectgcloud-node datastore key
dataObjectto 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

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago