

Node.js idiomatic client for Cloud Datastore.
Cloud Datastore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. While the Cloud Datastore interface has many of the same features as traditional databases, as a NoSQL database it differs from them in the way it describes relationships between data objects.
Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in Client Libraries Explained.
Table of contents:
Quickstart
Before you begin
-
Select or create a Cloud Platform project.
Go to the projects page
-
Enable billing for your project.
Enable billing
-
Enable the Google Cloud Datastore API.
Enable the API
-
Set up authentication with a service account so you can access the
API from your local workstation.
Installing the client library
npm install --save @google-cloud/datastore
Using the client library
const {Datastore} = require('@google-cloud/datastore');
const projectId = 'YOUR_PROJECT_ID';
const datastore = new Datastore({
projectId: projectId,
});
const kind = 'Task';
const name = 'sampletask1';
const taskKey = datastore.key([kind, name]);
const task = {
key: taskKey,
data: {
description: 'Buy milk',
},
};
datastore
.save(task)
.then(() => {
console.log(`Saved ${task.key.name}: ${task.data.description}`);
})
.catch(err => {
console.error('ERROR:', err);
});
Samples
Samples are in the samples/
directory. The samples' README.md
has instructions for running the samples.
The Cloud Datastore Node.js Client API Reference documentation
also contains samples.
Versioning
This library follows Semantic Versioning.
This library is considered to be General Availability (GA). This means it
is stable; the code surface will not change in backwards-incompatible ways
unless absolutely necessary (e.g. because of critical security issues) or with
an extensive deprecation period. Issues and requests against GA libraries
are addressed with the highest priority.
More Information: Google Cloud Platform Launch Stages
Contributing
Contributions welcome! See the Contributing Guide.
License
Apache Version 2.0
See LICENSE
v3.0.0
01-14-2019 20:31 PST
This release has breaking changes! The import style of this library has changed to be consistent with es modules.
Old busted code
const Datastore = require('@google-cloud/datastore')();
// or...
const Datastore = require('@google-cloud/datastore');
const ds = new Datastore();
New hot code
const {Datastore} = require('@google-cloud/datastore');
const ds = new Datastore();
Please take care to update your imports accordingly!
Dependencies
- fix(deps): update dependency google-gax to ^0.23.0 (#296)
- fix(deps): update dependency google-gax to ^0.22.0 (#248)
- fix(deps): update dependency concat-stream to v2 (#290)
- refactor: remove async module usage (#272)
- fix(deps): update dependency through2 to v3 (#237)
- chore: remove unused dependencies (#226)
- fix(deps): update dependency google-proto-files to ^0.17.0 (#210)
Documentation
- fix(docs): fix namespace causing 404s (#294)
- fix(docs): remove unused long running operations types
- docs: Update doc comment showing structure of entity (#276)
- docs: update readme badges (#269)
- refactor(samples): Samples to use async/await
- docs: update auto-generated jsdoc comments (#245)
Internal / Testing Changes
- refactor: sprinkle some types about (#291)
- chore(deps): update dependency @types/sinon to v7.0.2 (#289)
- chore(deps): update dependency @types/sinon to v7 (#286)
- refactor(ts): enable lint and fix (#287)
- chore(build): inject yoshi automation key (#285)
- chore: update nyc and eslint configs (#284)
- chore: fix publish.sh permission +x (#282)
- fix(build): fix Kokoro release script (#281)
- build: add Kokoro configs for autorelease (#280)
- chore: always nyc report before calling codecov (#275)
- chore: nyc ignore build/test by default (#274)
- chore: update license file (#271)
- refactor: run gts fix (#265)
- chore(deps): update dependency typescript to ~3.2.0 (#264)
- fix(build): fix system key decryption (#266)
- refactor(samples): convert sample tests from ava to mocha (#259)
- fix: Pin @types/sinon to last compatible version (#256)
- chore: add synth.metadata (#254)
- refactor(ts): enable noImplicitThis (#250)
- chore(deps): update dependency gts to ^0.9.0 (#247)
- chore: update eslintignore config (#246)
- refactor(ts): use es module imports (#244)
- chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 (#243)
- chore: drop contributors from multiple places (#241)
- chore(deps): update dependency @types/is to v0.0.21 (#240)
- chore: use latest npm on Windows (#239)
- refactor(ts): convert to typescript (#236)
- chore: update CircleCI config (#235)
- chore: include build in eslintignore (#232)
- chore(deps): update dependency eslint-plugin-node to v8 (#227)
- chore: update issue templates (#225)
- chore: remove old issue template (#223)
- build: run tests on node11 (#222)
- chores(build): do not collect sponge.xml from windows builds (#221)
- chores(build): run codecov on continuous builds (#220)
- chore: update new issue template (#219)
- build: fix codecov uploading on Kokoro (#213)
- fix(deps): update dependency sinon to v7 (#212)
- Update kokoro config (#207)
- chore(deps): update dependency eslint-plugin-prettier to v3 (#206)