-
Notifications
You must be signed in to change notification settings - Fork 653
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
This code only works if you are logued using gcloud cli.
I we are using credentials for this (keyFile.json) its kinda weird to also need to log in on the gcloud cli.
var gcloud = require('gcloud');
// Authenticating on a per-API-basis. You don't need to do this if you auth on a
// global basis (see Authentication section above).
var dataset = gcloud.datastore.dataset({
projectId: 'central-station-staging',
keyFilename: './keyFile.json'
});
dataset.get(dataset.key(['Product', 'Computer']), function(err, entity) {
console.log(err || entity);
});
// Save data to your dataset.
var blogPostData = {
title: 'How to make the perfect homemade pasta',
author: 'Andrew Chilton',
isDraft: true
};
var blogPostKey = dataset.key('BlogPost');
dataset.save({
key: blogPostKey,
data: blogPostData
}, function(err) {
// `blogPostKey` has been updated with an ID so you can do more operations
// with it, such as an update.
blogPostData.isDraft = false;
dataset.save({
key: blogPostKey,
data: blogPostData
}, function(err) {
if (!err) {
// The blog post is now published!
}
});
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.