Skip to content

Commit 6ef9960

Browse files
WalterHubJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
Uses 'category' instead of 'type' as a property name (#455)
1 parent 3618dce commit 6ef9960

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

datastore/api/index.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ indexes:
1919
- name: created
2020
- kind: Task
2121
properties:
22-
- name: type
22+
- name: category
2323
- name: priority
2424
- kind: Task
2525
properties:

datastore/api/snippets.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def basic_entity(client):
6262
# [START basic_entity]
6363
task = datastore.Entity(client.key('Task'))
6464
task.update({
65-
'type': 'Personal',
65+
'category': 'Personal',
6666
'done': False,
6767
'priority': 4,
6868
'description': 'Learn Cloud Datastore'
@@ -80,7 +80,7 @@ def entity_with_parent(client):
8080
task = datastore.Entity(key=key_with_parent)
8181

8282
task.update({
83-
'type': 'Personal',
83+
'category': 'Personal',
8484
'done': False,
8585
'priority': 4,
8686
'description': 'Learn Cloud Datastore'
@@ -97,7 +97,7 @@ def properties(client):
9797
key,
9898
exclude_from_indexes=['description'])
9999
task.update({
100-
'type': 'Personal',
100+
'category': 'Personal',
101101
'description': 'Learn Cloud Datastore',
102102
'created': datetime.datetime.utcnow(),
103103
'done': False,
@@ -135,7 +135,7 @@ def upsert(client):
135135
task = datastore.Entity(key=complete_key)
136136

137137
task.update({
138-
'type': 'Personal',
138+
'category': 'Personal',
139139
'done': False,
140140
'priority': 4,
141141
'description': 'Learn Cloud Datastore'
@@ -155,7 +155,7 @@ def insert(client):
155155
task = datastore.Entity(key=incomplete_key)
156156

157157
task.update({
158-
'type': 'Personal',
158+
'category': 'Personal',
159159
'done': False,
160160
'priority': 4,
161161
'description': 'Learn Cloud Datastore'
@@ -212,7 +212,7 @@ def batch_upsert(client):
212212
task1 = datastore.Entity(client.key('Task', 1))
213213

214214
task1.update({
215-
'type': 'Personal',
215+
'category': 'Personal',
216216
'done': False,
217217
'priority': 4,
218218
'description': 'Learn Cloud Datastore'
@@ -221,7 +221,7 @@ def batch_upsert(client):
221221
task2 = datastore.Entity(client.key('Task', 2))
222222

223223
task2.update({
224-
'type': 'Work',
224+
'category': 'Work',
225225
'done': False,
226226
'priority': 8,
227227
'description': 'Integrate Cloud Datastore'
@@ -296,7 +296,7 @@ def projection_query(client):
296296
# Create the entity that we're going to query.
297297
task = datastore.Entity(client.key('Task'))
298298
task.update({
299-
'type': 'Personal',
299+
'category': 'Personal',
300300
'done': False,
301301
'priority': 4,
302302
'description': 'Learn Cloud Datastore',
@@ -325,7 +325,7 @@ def ancestor_query(client):
325325
task = datastore.Entity(
326326
client.key('TaskList', 'default', 'Task'))
327327
task.update({
328-
'type': 'Personal',
328+
'category': 'Personal',
329329
'description': 'Learn Cloud Datastore',
330330
})
331331
client.put(task)
@@ -477,9 +477,9 @@ def distinct_query(client):
477477

478478
# [START distinct_query]
479479
query = client.query(kind='Task')
480-
query.distinct_on = ['type', 'priority']
481-
query.order = ['type', 'priority']
482-
query.projection = ['type', 'priority']
480+
query.distinct_on = ['category', 'priority']
481+
query.order = ['category', 'priority']
482+
query.projection = ['category', 'priority']
483483
# [END distinct_query]
484484

485485
return list(query.fetch())
@@ -491,8 +491,8 @@ def distinct_on_query(client):
491491

492492
# [START distinct_on_query]
493493
query = client.query(kind='Task')
494-
query.distinct_on = ['type']
495-
query.order = ['type', 'priority']
494+
query.distinct_on = ['category']
495+
query.order = ['category', 'priority']
496496
# [END distinct_on_query]
497497

498498
return list(query.fetch())

0 commit comments

Comments
 (0)