@@ -159,6 +159,8 @@ def add_example_data():
159
159
db = firestore .Client ()
160
160
# [START add_example_data]
161
161
cities_ref = db .collection (u'cities' )
162
+ cities_ref .document (u'BJ' ).set (
163
+ City (u'Beijing' , None , u'China' , True , 21500000 , [u'hebei' ]).to_dict ())
162
164
cities_ref .document (u'SF' ).set (
163
165
City (u'San Francisco' , u'CA' , u'USA' , False , 860000 ,
164
166
[u'west_coast' , u'norcal' ]).to_dict ())
@@ -171,8 +173,6 @@ def add_example_data():
171
173
cities_ref .document (u'TOK' ).set (
172
174
City (u'Tokyo' , None , u'Japan' , True , 9000000 ,
173
175
[u'kanto' , u'honshu' ]).to_dict ())
174
- cities_ref .document (u'BJ' ).set (
175
- City (u'Beijing' , None , u'China' , True , 21500000 , [u'hebei' ]).to_dict ())
176
176
# [END add_example_data]
177
177
178
178
@@ -304,8 +304,9 @@ def structure_subcollection_ref():
304
304
305
305
def update_doc ():
306
306
db = firestore .Client ()
307
- doc_ref = db .collection (u'cities' ).document (u'DC' )
308
- doc_ref .set ({})
307
+ db .collection (u'cities' ).document (u'DC' ).set (
308
+ City (u'Washington D.C.' , None , u'USA' , True , 680000 ,
309
+ [u'east_coast' ]).to_dict ())
309
310
310
311
# [START update_doc]
311
312
city_ref = db .collection (u'cities' ).document (u'DC' )
@@ -317,8 +318,9 @@ def update_doc():
317
318
318
319
def update_doc_array ():
319
320
db = firestore .Client ()
320
- doc_ref = db .collection (u'cities' ).document (u'DC' )
321
- doc_ref .set ({})
321
+ db .collection (u'cities' ).document (u'DC' ).set (
322
+ City (u'Washington D.C.' , None , u'USA' , True , 680000 ,
323
+ [u'east_coast' ]).to_dict ())
322
324
323
325
# [START fs_update_doc_array]
324
326
city_ref = db .collection (u'cities' ).document (u'DC' )
@@ -335,8 +337,9 @@ def update_doc_array():
335
337
336
338
def update_multiple ():
337
339
db = firestore .Client ()
338
- doc_ref = db .collection (u'cities' ).document (u'DC' )
339
- doc_ref .set ({})
340
+ db .collection (u'cities' ).document (u'DC' ).set (
341
+ City (u'Washington D.C.' , None , u'USA' , True , 680000 ,
342
+ [u'east_coast' ]).to_dict ())
340
343
341
344
# [START update_multiple]
342
345
doc_ref = db .collection (u'cities' ).document (u'DC' )
0 commit comments