-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e941b43
commit fe4f73a
Showing
8 changed files
with
1,183 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.