Simplified, more consistent API for Google Cloud Datastore.
Dstore implements a slightly more accessible version of the Google Cloud Datastore: Node.js Client
@google-cloud/datastore is a strange beast: The documentation is auto generated missing some core methods and completely shy of documenting any advanced concepts.
Also the typings are strange and overly broad.
Dstore tries to abstract away most surprises the datastore provides to you but als tries to stay as API compatible as possible to @google-cloud/datastore.
Main differences:
DstoreEntry
.(key, value)
and always returns the complete Key
of the entity being written.@ndb.transactional
feature. This is implemented via node's AsyncLocalStorage.DEBUG='ds:api'
allows you to trace API calls.Find the full documentation here. In there also some of the idiosyncrasies of using the Datastore are explained.
See the API documentation for Details, Github for source.
get_entity_group_version()
/ getEntityGroupVersion()
API has been retired. You can still for key
query { path: [key.path[0], {'kind': '__entity_group__', 'id': 1}]}
to get a __version__
property. The reliability of this data on FireStore is unknown.[Symbol(KEY)]
to represent the Key in an entity. This results in all kinds of confusion when serializing to JSON, e.g. for caching. This library adds the property _keyStr
which will be transparently used to regenerate [Symbol(KEY)]
when needed.get([key])
instead of get(key)
.insert()
and save()
sometimes return the key being written and sometimes not. So you might or might not get some data in insertResponse?.[0].mutationResults?.[0]?.key?.path
- urgs.key.id
is (usually but not always) returned as a String but you have to provide a Number to the API.Datastore-API is instrumented with prom-client. Metrics are all prefixed with dstore_
.
In an express based Application you can make them available like this:
import promClient from 'prom-client';
server.get('/metrics', async (req, res) => {
try {
res.set('Content-Type', promClient.register.contentType);
res.end(await promClient.register.metrics());
} catch (ex) {
res.status(500).end(ex);
}
});
Google Documentation
API Simplification
ORM / Schema
Others
Generated using TypeDoc