google-cloud-datastore 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,10 @@ module Google
34
34
  # Properties, and Keys
35
35
  #
36
36
  # @example Create a new entity using a block:
37
+ # require "google/cloud/datastore"
38
+ #
39
+ # datastore = Google::Cloud::Datastore.new
40
+ #
37
41
  # task = datastore.entity "Task", "sampleTask" do |t|
38
42
  # t["type"] = "Personal"
39
43
  # t["created"] = Time.now
@@ -44,6 +48,10 @@ module Google
44
48
  # end
45
49
  #
46
50
  # @example Create a new entity belonging to an existing parent entity:
51
+ # require "google/cloud/datastore"
52
+ #
53
+ # datastore = Google::Cloud::Datastore.new
54
+ #
47
55
  # task_key = datastore.key "Task", "sampleTask"
48
56
  # task_key.parent = datastore.key "TaskList", "default"
49
57
  #
@@ -84,6 +92,7 @@ module Google
84
92
  # require "google/cloud/datastore"
85
93
  #
86
94
  # datastore = Google::Cloud::Datastore.new
95
+ #
87
96
  # task = datastore.find "Task", "sampleTask"
88
97
  # task["description"] #=> "Learn Cloud Datastore"
89
98
  #
@@ -91,6 +100,7 @@ module Google
91
100
  # require "google/cloud/datastore"
92
101
  #
93
102
  # datastore = Google::Cloud::Datastore.new
103
+ #
94
104
  # task = datastore.find "Task", "sampleTask"
95
105
  # task[:description] #=> "Learn Cloud Datastore"
96
106
  #
@@ -98,23 +108,25 @@ module Google
98
108
  # require "google/cloud/datastore"
99
109
  #
100
110
  # datastore = Google::Cloud::Datastore.new
111
+ #
101
112
  # user = datastore.find "User", "alice"
102
- # user["avatar"] #=> StringIO("\x89PNG\r\n\x1A...")
113
+ # user["avatar"].class #=> StringIO
103
114
  #
104
115
  # @example Getting a geo point value returns a Hash:
105
116
  # require "google/cloud/datastore"
106
117
  #
107
118
  # datastore = Google::Cloud::Datastore.new
119
+ #
108
120
  # user = datastore.find "User", "alice"
109
- # user["location"] #=> { longitude: -122.0862462,
110
- # # latitude: 37.4220041 }
121
+ # user["location"].keys #=> [:latitude, :longitude]
111
122
  #
112
123
  # @example Getting a blob value returns a StringIO object:
113
124
  # require "google/cloud/datastore"
114
125
  #
115
126
  # datastore = Google::Cloud::Datastore.new
127
+ #
116
128
  # user = datastore.find "User", "alice"
117
- # user["avatar"] #=> StringIO("\x89PNG\r\n\x1A...")
129
+ # user["avatar"].class #=> StringIO
118
130
  #
119
131
  def [] prop_name
120
132
  properties[prop_name]
@@ -137,6 +149,7 @@ module Google
137
149
  # require "google/cloud/datastore"
138
150
  #
139
151
  # datastore = Google::Cloud::Datastore.new
152
+ #
140
153
  # task = datastore.find "Task", "sampleTask"
141
154
  # task["description"] = "Learn Cloud Datastore"
142
155
  # task["tags"] = ["fun", "programming"]
@@ -145,6 +158,7 @@ module Google
145
158
  # require "google/cloud/datastore"
146
159
  #
147
160
  # datastore = Google::Cloud::Datastore.new
161
+ #
148
162
  # task = datastore.find "Task", "sampleTask"
149
163
  # task[:description] = "Learn Cloud Datastore"
150
164
  # task[:tags] = ["fun", "programming"]
@@ -153,14 +167,16 @@ module Google
153
167
  # require "google/cloud/datastore"
154
168
  #
155
169
  # datastore = Google::Cloud::Datastore.new
170
+ #
156
171
  # user = datastore.find "User", "alice"
157
172
  # user["avatar"] = File.open "/avatars/alice.png"
158
- # user["avatar"] #=> StringIO("\x89PNG\r\n\x1A...")
173
+ # user["avatar"].class #=> StringIO
159
174
  #
160
175
  # @example Setting a geo point value using a Hash:
161
176
  # require "google/cloud/datastore"
162
177
  #
163
178
  # datastore = Google::Cloud::Datastore.new
179
+ #
164
180
  # user = datastore.find "User", "alice"
165
181
  # user["location"] = { longitude: -122.0862462, latitude: 37.4220041 }
166
182
  #
@@ -168,9 +184,10 @@ module Google
168
184
  # require "google/cloud/datastore"
169
185
  #
170
186
  # datastore = Google::Cloud::Datastore.new
187
+ #
171
188
  # user = datastore.find "User", "alice"
172
189
  # user["avatar"] = File.open "/avatars/alice.png"
173
- # user["avatar"] #=> StringIO("\x89PNG\r\n\x1A...")
190
+ # user["avatar"].class #=> StringIO
174
191
  #
175
192
  def []= prop_name, prop_value
176
193
  properties[prop_name] = prop_value
@@ -183,6 +200,12 @@ module Google
183
200
  # @return [Google::Cloud::Datastore::Properties]
184
201
  #
185
202
  # @example
203
+ # require "google/cloud/datastore"
204
+ #
205
+ # datastore = Google::Cloud::Datastore.new
206
+ #
207
+ # task = datastore.find "Task", "sampleTask"
208
+ #
186
209
  # task.properties[:description] = "Learn Cloud Datastore"
187
210
  # task.properties["description"] #=> "Learn Cloud Datastore"
188
211
  #
@@ -191,15 +214,33 @@ module Google
191
214
  # end
192
215
  #
193
216
  # @example A property's existence can be determined by calling `exist?`:
217
+ # require "google/cloud/datastore"
218
+ #
219
+ # datastore = Google::Cloud::Datastore.new
220
+ #
221
+ # task = datastore.find "Task", "sampleTask"
222
+ #
194
223
  # task.properties.exist? :description #=> true
195
224
  # task.properties.exist? "description" #=> true
196
225
  # task.properties.exist? :expiration #=> false
197
226
  #
198
227
  # @example A property can be removed from the entity:
228
+ # require "google/cloud/datastore"
229
+ #
230
+ # datastore = Google::Cloud::Datastore.new
231
+ #
232
+ # task = datastore.find "Task", "sampleTask"
233
+ #
199
234
  # task.properties.delete :description
200
- # task.save
235
+ # datastore.update task
201
236
  #
202
237
  # @example The properties can be converted to a hash:
238
+ # require "google/cloud/datastore"
239
+ #
240
+ # datastore = Google::Cloud::Datastore.new
241
+ #
242
+ # task = datastore.find "Task", "sampleTask"
243
+ #
203
244
  # prop_hash = task.properties.to_h
204
245
  #
205
246
  attr_reader :properties
@@ -214,6 +255,7 @@ module Google
214
255
  # require "google/cloud/datastore"
215
256
  #
216
257
  # datastore = Google::Cloud::Datastore.new
258
+ #
217
259
  # task = Google::Cloud::Datastore::Entity.new
218
260
  # task.key = datastore.key "Task"
219
261
  # datastore.save task
@@ -222,11 +264,12 @@ module Google
222
264
  # require "google/cloud/datastore"
223
265
  #
224
266
  # datastore = Google::Cloud::Datastore.new
267
+ #
225
268
  # task = datastore.find "Task", "sampleTask"
226
269
  # task.persisted? #=> true
227
- # task.key = datastore.key "Task" #=> RuntimeError
270
+ # task.key = datastore.key "Task" #=> raise RuntimeError
228
271
  # task.key.frozen? #=> true
229
- # task.key.id = 9876543221 #=> RuntimeError
272
+ # task.key.id = 9876543221 #=> raise RuntimeError
230
273
  #
231
274
  def key= new_key
232
275
  fail "This entity's key is immutable." if persisted?
@@ -268,10 +311,22 @@ module Google
268
311
  # Unindexed properties
269
312
  #
270
313
  # @example Single property values will return a single flag setting:
314
+ # require "google/cloud/datastore"
315
+ #
316
+ # datastore = Google::Cloud::Datastore.new
317
+ #
318
+ # task = datastore.find "Task", "sampleTask"
319
+ #
271
320
  # task["priority"] = 4
272
321
  # task.exclude_from_indexes? "priority" #=> false
273
322
  #
274
323
  # @example A multi-valued property will return array of flag settings:
324
+ # require "google/cloud/datastore"
325
+ #
326
+ # datastore = Google::Cloud::Datastore.new
327
+ #
328
+ # task = datastore.find "Task", "sampleTask"
329
+ #
275
330
  # task["tags"] = ["fun", "programming"]
276
331
  # task.exclude_from_indexes! "tags", [true, false]
277
332
  #
@@ -311,18 +366,42 @@ module Google
311
366
  # Unindexed properties
312
367
  #
313
368
  # @example
369
+ # require "google/cloud/datastore"
370
+ #
371
+ # datastore = Google::Cloud::Datastore.new
372
+ #
373
+ # entity = datastore.find "Task", "sampleTask"
374
+ #
314
375
  # entity["priority"] = 4
315
376
  # entity.exclude_from_indexes! "priority", true
316
377
  #
317
378
  # @example Multi-valued properties can be given multiple exclude flags:
379
+ # require "google/cloud/datastore"
380
+ #
381
+ # datastore = Google::Cloud::Datastore.new
382
+ #
383
+ # entity = datastore.find "Task", "sampleTask"
384
+ #
318
385
  # entity["tags"] = ["fun", "programming"]
319
386
  # entity.exclude_from_indexes! "tags", [true, false]
320
387
  #
321
388
  # @example Or, a single flag can be applied to all values in a property:
389
+ # require "google/cloud/datastore"
390
+ #
391
+ # datastore = Google::Cloud::Datastore.new
392
+ #
393
+ # entity = datastore.find "Task", "sampleTask"
394
+ #
322
395
  # entity["tags"] = ["fun", "programming"]
323
396
  # entity.exclude_from_indexes! "tags", true
324
397
  #
325
398
  # @example Flags can also be set with a block:
399
+ # require "google/cloud/datastore"
400
+ #
401
+ # datastore = Google::Cloud::Datastore.new
402
+ #
403
+ # entity = datastore.find "Task", "sampleTask"
404
+ #
326
405
  # entity["priority"] = 4
327
406
  # entity.exclude_from_indexes! "priority" do |priority|
328
407
  # priority > 4
@@ -31,6 +31,10 @@ module Google
31
31
  # Reference
32
32
  #
33
33
  # @example
34
+ # require "google/cloud/datastore"
35
+ #
36
+ # datastore = Google::Cloud::Datastore.new
37
+ #
34
38
  # gql_query = Google::Cloud::Datastore::GqlQuery.new
35
39
  # gql_query.query_string = "SELECT * FROM Task ORDER BY created ASC"
36
40
  # tasks = datastore.run gql_query
@@ -40,6 +44,8 @@ module Google
40
44
  # Returns a new GqlQuery instance.
41
45
  #
42
46
  # @example
47
+ # require "google/cloud/datastore"
48
+ #
43
49
  # gql_query = Google::Cloud::Datastore::GqlQuery.new
44
50
  #
45
51
  def initialize
@@ -102,6 +108,8 @@ module Google
102
108
  # literal values
103
109
  #
104
110
  # @example
111
+ # require "google/cloud/datastore"
112
+ #
105
113
  # gql_query = Google::Cloud::Datastore::GqlQuery.new
106
114
  # gql_query.query_string = "SELECT * FROM Task " \
107
115
  # "WHERE completed = false AND priority = 4"
@@ -138,6 +146,8 @@ module Google
138
146
  # names in the query string to valid GQL arguments
139
147
  #
140
148
  # @example
149
+ # require "google/cloud/datastore"
150
+ #
141
151
  # gql_query = Google::Cloud::Datastore::GqlQuery.new
142
152
  # gql_query.query_string = "SELECT * FROM Task " \
143
153
  # "WHERE done = @done " \
@@ -186,6 +196,8 @@ module Google
186
196
  # of the numbered binding sites in the query string
187
197
  #
188
198
  # @example
199
+ # require "google/cloud/datastore"
200
+ #
189
201
  # gql_query = Google::Cloud::Datastore::GqlQuery.new
190
202
  # gql_query.query_string = "SELECT * FROM Task" \
191
203
  # "WHERE completed = @1 AND priority = @2"
@@ -25,6 +25,8 @@ module Google
25
25
  # integer numeric ID, assigned automatically by Datastore.
26
26
  #
27
27
  # @example
28
+ # require "google/cloud/datastore"
29
+ #
28
30
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
29
31
  #
30
32
  class Key
@@ -34,6 +36,8 @@ module Google
34
36
  # @return [String]
35
37
  #
36
38
  # @example
39
+ # require "google/cloud/datastore"
40
+ #
37
41
  # key = Google::Cloud::Datastore::Key.new "TaskList"
38
42
  # key.kind #=> "TaskList"
39
43
  # key.kind = "Task"
@@ -88,6 +92,8 @@ module Google
88
92
  # @return [Google::Cloud::Datastore::Dataset::Key]
89
93
  #
90
94
  # @example
95
+ # require "google/cloud/datastore"
96
+ #
91
97
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
92
98
  #
93
99
  def initialize kind = nil, id_or_name = nil
@@ -106,6 +112,8 @@ module Google
106
112
  # @return [Integer, nil]
107
113
  #
108
114
  # @example
115
+ # require "google/cloud/datastore"
116
+ #
109
117
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
110
118
  # task_key.id #=> nil
111
119
  # task_key.name #=> "sampleTask"
@@ -124,6 +132,8 @@ module Google
124
132
  # @return [Integer, nil]
125
133
  #
126
134
  # @example
135
+ # require "google/cloud/datastore"
136
+ #
127
137
  # task_key = Google::Cloud::Datastore::Key.new "Task", 123456
128
138
  # task_key.id #=> 123456
129
139
  #
@@ -136,6 +146,8 @@ module Google
136
146
  # @return [String, nil]
137
147
  #
138
148
  # @example
149
+ # require "google/cloud/datastore"
150
+ #
139
151
  # task_key = Google::Cloud::Datastore::Key.new "Task", 123456
140
152
  # task_key.id #=> 123456
141
153
  # task_key.name #=> nil
@@ -154,6 +166,8 @@ module Google
154
166
  # @return [String, nil]
155
167
  #
156
168
  # @example
169
+ # require "google/cloud/datastore"
170
+ #
157
171
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
158
172
  # task_key.name #=> "sampleTask"
159
173
  #
@@ -165,11 +179,15 @@ module Google
165
179
  # @return [Key, nil]
166
180
  #
167
181
  # @example
182
+ # require "google/cloud/datastore"
183
+ #
168
184
  # parent_key = Google::Cloud::Datastore::Key.new "TaskList", "default"
169
185
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
170
186
  # task_key.parent = parent_key
171
187
  #
172
188
  # @example With multiple levels:
189
+ # require "google/cloud/datastore"
190
+ #
173
191
  # user_key = Google::Cloud::Datastore::Key.new "User", "alice"
174
192
  # list_key = Google::Cloud::Datastore::Key.new "TaskList", "default"
175
193
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
@@ -196,7 +214,7 @@ module Google
196
214
  # query = datastore.query("Task").
197
215
  # ancestor(task_list)
198
216
  # lists = datastore.run query
199
- # lists.first.key.parent #=> Key("TaskList", "default")
217
+ # lists.first.key.parent # Key("TaskList", "default")
200
218
  #
201
219
  attr_reader :parent
202
220
 
@@ -208,6 +226,8 @@ module Google
208
226
  # @return [Array<Array<(String, String)>>]
209
227
  #
210
228
  # @example
229
+ # require "google/cloud/datastore"
230
+ #
211
231
  # parent_key = Google::Cloud::Datastore::Key.new "TaskList", "default"
212
232
  # task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
213
233
  # task_key.parent = parent_key
@@ -30,6 +30,10 @@ module Google
30
30
  # Datastore Metadata
31
31
  #
32
32
  # @example
33
+ # require "google/cloud/datastore"
34
+ #
35
+ # datastore = Google::Cloud::Datastore.new
36
+ #
33
37
  # query = Google::Cloud::Datastore::Query.new
34
38
  # query.kind("Task").
35
39
  # where("done", "=", false).
@@ -43,6 +47,8 @@ module Google
43
47
  # Returns a new query object.
44
48
  #
45
49
  # @example
50
+ # require "google/cloud/datastore"
51
+ #
46
52
  # query = Google::Cloud::Datastore::Query.new
47
53
  #
48
54
  def initialize
@@ -57,6 +63,10 @@ module Google
57
63
  # queries](https://cloud.google.com/datastore/docs/concepts/metadataqueries).
58
64
  #
59
65
  # @example
66
+ # require "google/cloud/datastore"
67
+ #
68
+ # datastore = Google::Cloud::Datastore.new
69
+ #
60
70
  # query = Google::Cloud::Datastore::Query.new
61
71
  # query.kind "Task"
62
72
  #
@@ -76,6 +86,10 @@ module Google
76
86
  # Add a property filter to the query.
77
87
  #
78
88
  # @example
89
+ # require "google/cloud/datastore"
90
+ #
91
+ # datastore = Google::Cloud::Datastore.new
92
+ #
79
93
  # query = Google::Cloud::Datastore::Query.new
80
94
  # query.kind("Task").
81
95
  # where("done", "=", false)
@@ -83,6 +97,10 @@ module Google
83
97
  # tasks = datastore.run query
84
98
  #
85
99
  # @example Add a composite property filter:
100
+ # require "google/cloud/datastore"
101
+ #
102
+ # datastore = Google::Cloud::Datastore.new
103
+ #
86
104
  # query = Google::Cloud::Datastore::Query.new
87
105
  # query.kind("Task").
88
106
  # where("done", "=", false).
@@ -91,6 +109,10 @@ module Google
91
109
  # tasks = datastore.run query
92
110
  #
93
111
  # @example Add an inequality filter on a **single** property only:
112
+ # require "google/cloud/datastore"
113
+ #
114
+ # datastore = Google::Cloud::Datastore.new
115
+ #
94
116
  # query = Google::Cloud::Datastore::Query.new
95
117
  # query.kind("Task").
96
118
  # where("created", ">=", Time.utc(1990, 1, 1)).
@@ -99,6 +121,10 @@ module Google
99
121
  # tasks = datastore.run query
100
122
  #
101
123
  # @example Add a composite filter on an array property:
124
+ # require "google/cloud/datastore"
125
+ #
126
+ # datastore = Google::Cloud::Datastore.new
127
+ #
102
128
  # query = Google::Cloud::Datastore::Query.new
103
129
  # query.kind("Task").
104
130
  # where("tag", "=", "fun").
@@ -107,6 +133,10 @@ module Google
107
133
  # tasks = datastore.run query
108
134
  #
109
135
  # @example Add an inequality filter on an array property :
136
+ # require "google/cloud/datastore"
137
+ #
138
+ # datastore = Google::Cloud::Datastore.new
139
+ #
110
140
  # query = Google::Cloud::Datastore::Query.new
111
141
  # query.kind("Task").
112
142
  # where("tag", ">", "learn").
@@ -115,6 +145,10 @@ module Google
115
145
  # tasks = datastore.run query
116
146
  #
117
147
  # @example Add a key filter using the special property `__key__`:
148
+ # require "google/cloud/datastore"
149
+ #
150
+ # datastore = Google::Cloud::Datastore.new
151
+ #
118
152
  # query = Google::Cloud::Datastore::Query.new
119
153
  # query.kind("Task").
120
154
  # where("__key__", ">", datastore.key("Task", "someTask"))
@@ -122,6 +156,10 @@ module Google
122
156
  # tasks = datastore.run query
123
157
  #
124
158
  # @example Add a key filter to a *kindless* query:
159
+ # require "google/cloud/datastore"
160
+ #
161
+ # datastore = Google::Cloud::Datastore.new
162
+ #
125
163
  # last_seen_key = datastore.key "Task", "a"
126
164
  # query = Google::Cloud::Datastore::Query.new
127
165
  # query.where("__key__", ">", last_seen_key)
@@ -152,6 +190,10 @@ module Google
152
190
  # Add a filter for entities that inherit from a key.
153
191
  #
154
192
  # @example
193
+ # require "google/cloud/datastore"
194
+ #
195
+ # datastore = Google::Cloud::Datastore.new
196
+ #
155
197
  # task_list_key = datastore.key "TaskList", "default"
156
198
  #
157
199
  # query = Google::Cloud::Datastore::Query.new
@@ -173,6 +215,10 @@ module Google
173
215
  # of a string or symbol that starts with "d".
174
216
  #
175
217
  # @example With ascending sort order:
218
+ # require "google/cloud/datastore"
219
+ #
220
+ # datastore = Google::Cloud::Datastore.new
221
+ #
176
222
  # query = Google::Cloud::Datastore::Query.new
177
223
  # query.kind("Task").
178
224
  # order("created")
@@ -180,6 +226,10 @@ module Google
180
226
  # tasks = datastore.run query
181
227
  #
182
228
  # @example With descending sort order:
229
+ # require "google/cloud/datastore"
230
+ #
231
+ # datastore = Google::Cloud::Datastore.new
232
+ #
183
233
  # query = Google::Cloud::Datastore::Query.new
184
234
  # query.kind("Task").
185
235
  # order("created", :desc)
@@ -187,6 +237,10 @@ module Google
187
237
  # tasks = datastore.run query
188
238
  #
189
239
  # @example With multiple sort orders:
240
+ # require "google/cloud/datastore"
241
+ #
242
+ # datastore = Google::Cloud::Datastore.new
243
+ #
190
244
  # query = Google::Cloud::Datastore::Query.new
191
245
  # query.kind("Task").
192
246
  # order("priority", :desc).
@@ -195,6 +249,10 @@ module Google
195
249
  # tasks = datastore.run query
196
250
  #
197
251
  # @example A property used in inequality filter must be ordered first:
252
+ # require "google/cloud/datastore"
253
+ #
254
+ # datastore = Google::Cloud::Datastore.new
255
+ #
198
256
  # query = Google::Cloud::Datastore::Query.new
199
257
  # query.kind("Task").
200
258
  # where("priority", ">", 3).
@@ -217,6 +275,10 @@ module Google
217
275
  # Set a limit on the number of results to be returned.
218
276
  #
219
277
  # @example
278
+ # require "google/cloud/datastore"
279
+ #
280
+ # datastore = Google::Cloud::Datastore.new
281
+ #
220
282
  # query = Google::Cloud::Datastore::Query.new
221
283
  # query.kind("Task").
222
284
  # limit(5)
@@ -233,6 +295,10 @@ module Google
233
295
  # Set an offset for the results to be returned.
234
296
  #
235
297
  # @example
298
+ # require "google/cloud/datastore"
299
+ #
300
+ # datastore = Google::Cloud::Datastore.new
301
+ #
236
302
  # query = Google::Cloud::Datastore::Query.new
237
303
  # query.kind("Task").
238
304
  # limit(5).
@@ -250,6 +316,10 @@ module Google
250
316
  # Set the cursor to start the results at.
251
317
  #
252
318
  # @example
319
+ # require "google/cloud/datastore"
320
+ #
321
+ # datastore = Google::Cloud::Datastore.new
322
+ #
253
323
  # query = Google::Cloud::Datastore::Query.new
254
324
  # query.kind("Task").
255
325
  # limit(page_size).
@@ -274,6 +344,10 @@ module Google
274
344
  # Retrieve only select properties from the matched entities.
275
345
  #
276
346
  # @example
347
+ # require "google/cloud/datastore"
348
+ #
349
+ # datastore = Google::Cloud::Datastore.new
350
+ #
277
351
  # query = Google::Cloud::Datastore::Query.new
278
352
  # query.kind("Task").
279
353
  # select("priority", "percent_complete")
@@ -286,6 +360,10 @@ module Google
286
360
  # end
287
361
  #
288
362
  # @example A keys-only query using the special property `__key__`:
363
+ # require "google/cloud/datastore"
364
+ #
365
+ # datastore = Google::Cloud::Datastore.new
366
+ #
289
367
  # query = Google::Cloud::Datastore::Query.new
290
368
  # query.kind("Task").
291
369
  # select("__key__")
@@ -308,6 +386,10 @@ module Google
308
386
  # Group results by a list of properties.
309
387
  #
310
388
  # @example
389
+ # require "google/cloud/datastore"
390
+ #
391
+ # datastore = Google::Cloud::Datastore.new
392
+ #
311
393
  # query = Google::Cloud::Datastore::Query.new
312
394
  # query.kind("Task").
313
395
  # distinct_on("type", "priority").