Skip to content

Instantly share code, notes, and snippets.

@wayneashleyberry
Last active April 11, 2017 14:32
Show Gist options
  • Save wayneashleyberry/5b9219346afbab974a263f4b073bd831 to your computer and use it in GitHub Desktop.
Save wayneashleyberry/5b9219346afbab974a263f4b073bd831 to your computer and use it in GitHub Desktop.
Datastore example
const datastore = require('@google-cloud/datastore')();
const key1 = datastore.key(['Users', 1, 'Comments']);
const comment1 = {
userId: 1,
commentBody: '...',
ts: new Date(),
};
const key2 = datastore.key(['Users', 2, 'Comments']);
const comment2 = {
userId: 2,
commentBody: '...',
ts: new Date(),
};
datastore.save({
key: key1,
data: comment1
}, (err) => {
//
});
datastore.save({
key: key2,
data: comment2
}, (err) => {
//
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment