You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, install <code>gcloud</code> with npm and require it into your project:
20
27
</p>
21
28
<divhljs>$ npm install --save gcloud</div>
22
29
<divhljs>var gcloud = require('gcloud');</div>
30
+
<p>
31
+
There are a couple of ways to use the <code>gcloud</code> module.
32
+
</p>
33
+
<p>
34
+
If you are running your app on Google App Engine or Google Compute Engine, you won't need to worry about supplying connection configuration options to <code>gcloud</code>— we figure that out for you.
35
+
</p>
36
+
<p>
37
+
However, if you're running your app elsewhere, you will need to provide this information.
38
+
</p>
39
+
<divhljs>
40
+
// App Engine and Compute Engine
41
+
var gcloud = require('gcloud');
23
42
24
-
<articleng-if="isActiveDoc('datastore')">
25
-
<p>
26
-
The <code>gcloud.datastore</code> object gives you some convenience methods, as well as exposes a <code>Dataset</code> function. This will allow you to create a <code>Dataset</code>, which is the object from which you will interact with the Google Cloud Datastore.
27
-
</p>
28
-
<divhljs>
43
+
// Elsewhere
44
+
var gcloud = require('gcloud')({
45
+
keyFilename: '/path/to/keyfile.json'
46
+
});</div>
47
+
<p>
48
+
In any environment, you are free to provide these and other default properties, which eventually will be passed to the <code>gcloud</code> sub-modules (Datastore, Storage, etc.).
49
+
</p>
50
+
</article>
51
+
<hr>
52
+
<articleng-if="isActiveDoc('datastore')">
53
+
<h2>Overview</h2>
54
+
<p>
55
+
The <code>gcloud.datastore</code> object gives you some convenience methods, as well as exposes a <code>dataset</code> function. This will allow you to create a <code>dataset</code>, which is the object from which you will interact with the Google Cloud Datastore.
See <ahref="#/docs/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others.
33
-
</p>
34
-
</article>
35
-
36
-
<articleng-if="isActiveDoc('storage')">
37
-
<p>
38
-
The <code>gcloud.storage</code> object contains a <code>Bucket</code> object, which is how you will interact with your Google Cloud Storage bucket.
39
-
</p>
40
-
<divhljs>
41
-
var storage = gcloud.storage;
42
-
var bucket = new storage.Bucket({
43
-
bucketName: 'MyBucket'
59
+
var dataset = datastore.dataset({
60
+
projectId: 'myProject',
61
+
keyFilename: '/path/to/keyfile.json'
44
62
});</div>
45
-
<p>
46
-
See examples below for more on how to upload a file, read from your bucket's files, create signed URLs, and more.
See <ahref="#/docs/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others.
65
+
</p>
66
+
</article>
67
+
<articleng-if="isActiveDoc('storage')">
68
+
<h2>Overview</h2>
69
+
<p>
70
+
The <code>gcloud.storage</code> object contains a <code>bucket</code> object, which is how you will interact with your Google Cloud Storage bucket. See the guide on <ahref="https://developers.google.com/storage">Google Cloud Storage</a> to create a bucket.
71
+
</p>
72
+
<p>
73
+
See examples below for more on how to access your bucket to upload a file, read its files, create signed URLs, and more.
"string": "var key;\n\n// Create a key from the dataset's namespace.\nkey = dataset.key('Company', 123);\n\n// Create a key from a provided namespace and path.\nkey = dataset.key({\n namespace: 'My-NS',\n path: ['Company', 123]\n});"
254
+
"string": "// Create a key from the dataset's namespace.\nvar Company123 = dataset.key('Company', 123);\n\n// Create a key from a provided namespace and path.\nvar NSCompany123 = dataset.key({\n namespace: 'My-NS',\n path: ['Company', 123]\n});"
"full": "<p>Developer Documentation</p><p>Invoking the Datastore class allows you to provide configuration up-front.<br />This configuration will be used for future invokations of the returned<br /><code>dataset</code> method.</p>",
98
+
"summary": "<p>Developer Documentation</p>",
99
+
"body": "<p>Invoking the Datastore class allows you to provide configuration up-front.<br />This configuration will be used for future invokations of the returned<br /><code>dataset</code> method.</p>"
"full": "<p>Developer Documentation</p><p>Use this static method to create a dataset without any pre-configured<br />options.</p>",
142
+
"summary": "<p>Developer Documentation</p>",
143
+
"body": "<p>Use this static method to create a dataset without any pre-configured<br />options.</p>"
144
+
},
145
+
"isPrivate": false,
146
+
"ignore": true,
147
+
"code": "Datastore.dataset = Dataset;",
77
148
"ctx": {
78
149
"type": "property",
79
-
"receiver": "datastore",
80
-
"name": "Dataset",
81
-
"value": "require('./dataset')",
82
-
"string": "datastore.Dataset"
150
+
"receiver": "Datastore",
151
+
"name": "dataset",
152
+
"value": "Dataset",
153
+
"string": "Datastore.dataset"
154
+
}
155
+
},
156
+
{
157
+
"tags": [
158
+
{
159
+
"type": "param",
160
+
"types": [
161
+
"object="
162
+
],
163
+
"name": "options",
164
+
"description": "- Configuration object."
165
+
},
166
+
{
167
+
"type": "return",
168
+
"types": [
169
+
"module:datastore",
170
+
"dataset"
171
+
],
172
+
"description": ""
173
+
}
174
+
],
175
+
"description": {
176
+
"full": "<p>Developer Documentation</p><p>Create a dataset using the instance method when you want to use your<br />pre-configured options from the Datastore instance.</p>",
177
+
"summary": "<p>Developer Documentation</p>",
178
+
"body": "<p>Create a dataset using the instance method when you want to use your<br />pre-configured options from the Datastore instance.</p>"
179
+
},
180
+
"isPrivate": false,
181
+
"ignore": true,
182
+
"code": "Datastore.prototype.dataset = function(options) {\n // Mix in global config data to the provided options.\n return new Dataset(util.extend(true, {}, this.config, options));\n};",
183
+
"ctx": {
184
+
"type": "method",
185
+
"constructor": "Datastore",
186
+
"cons": "Datastore",
187
+
"name": "dataset",
188
+
"string": "Datastore.prototype.dataset()"
83
189
}
84
190
},
85
191
{
@@ -111,12 +217,12 @@
111
217
},
112
218
"isPrivate": false,
113
219
"ignore": false,
114
-
"code": "datastore.int = function(value) {\n return new entity.Int(value);\n};",
220
+
"code": "Datastore.int = function(value) {\n return new entity.Int(value);\n};",
115
221
"ctx": {
116
222
"type": "method",
117
-
"receiver": "datastore",
223
+
"receiver": "Datastore",
118
224
"name": "int",
119
-
"string": "datastore.int()"
225
+
"string": "Datastore.int()"
120
226
}
121
227
},
122
228
{
@@ -148,12 +254,12 @@
148
254
},
149
255
"isPrivate": false,
150
256
"ignore": false,
151
-
"code": "datastore.double = function(value) {\n return new entity.Double(value);\n};\n\nmodule.exports = datastore;",
257
+
"code": "Datastore.double = function(value) {\n return new entity.Double(value);\n};\n\nmodule.exports = Datastore;",
0 commit comments