Skip to content

Commit

Permalink
add datastore v1beta3 snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Oct 19, 2015
1 parent e941b43 commit fe4f73a
Show file tree
Hide file tree
Showing 8 changed files with 1,183 additions and 0 deletions.
415 changes: 415 additions & 0 deletions datastore/entity.js

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions datastore/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

var gcloud = require('gcloud');

// This mock is used in the documentation snippets.
var datastore = {
insert: function() {}
};

function Index(projectId) {
this.datastore = gcloud.datastore({
projectId: projectId
});
}

Index.prototype.testUnindexedPropertyQuery = function(callback) {
var datastore = this.datastore;

// [START unindexed_property_query]
var query = datastore.createQuery('Task')
.filter('description =', 'A task description.');
// [END unindexed_property_query]

this.datastore.runQuery(query, callback);
};

Index.prototype.testExplodingProperties = function(callback) {
datastore.key = this.datastore.key;

// [START exploding_properties]
var task = {
key: datastore.key('Task'),
data: {
tags: [
'fun',
'programming',
'learn'
],
collaborators: [
'alice',
'bob',
'charlie'
],
created: new Date()
}
};

datastore.insert(task, function(err) {
if (!err) {
// Task inserted successfully.
}
});
// [END exploding_properties]

delete datastore.key;

this.datastore.insert(task, callback);
};

module.exports = Index;
Loading

0 comments on commit fe4f73a

Please sign in to comment.