@@ -40,7 +40,9 @@ the collection named ``Movies``, use ``set()`` method.
40
40
" lead" : {
41
41
" name" : " Robert Downey Jr."
42
42
},
43
+ ' cast' : [' Gwyneth Paltrow' ]
43
44
' released' : False ,
45
+ ' prequel' : None
44
46
}
45
47
46
48
fsdb.collection(' Marvels' ).document(' Movies' ).set(data)
@@ -61,6 +63,8 @@ To read data from an existing document of an collection, use ``get()`` method.
61
63
fsdb.collection(' Marvels' ).document(' Movies' ).get()
62
64
..
63
65
66
+
67
+
64
68
It is possible to filter the data of an document to receive specific fields.
65
69
66
70
.. code-block :: python
@@ -76,8 +80,7 @@ It is possible to filter the data of an document to receive specific fields.
76
80
Update Data
77
81
-----------
78
82
79
- To update existing data or add more data to an existing document, use
80
- ``update() `` method.
83
+ To add more data to an existing document, use ``update() `` method.
81
84
82
85
.. code-block :: python
83
86
@@ -90,6 +93,10 @@ To update existing data or add more data to an existing document, use
90
93
fsdb.collection(' Marvels' ).document(' Movies' ).update(data)
91
94
..
92
95
96
+
97
+
98
+ To update existing data to an existing document, use ``update() `` method.
99
+
93
100
.. code-block :: python
94
101
95
102
# update data of an existing document
@@ -102,9 +109,53 @@ To update existing data or add more data to an existing document, use
102
109
..
103
110
104
111
112
+
113
+ To add an item to an array field in an existing document, use
114
+ ``update() `` method.
115
+
116
+ .. code-block :: python
117
+
118
+ from google.cloud.firestore import ArrayUnion
119
+ data = {
120
+ ' cast' : ArrayUnion([' Terrence Howard' ])
121
+ }
122
+
123
+ fsdb.collection(' Marvels' ).document(' Movies' ).update(data)
124
+ ..
125
+
126
+
105
127
Delete Data
106
128
-----------
107
129
130
+ To remove an field from an existing document, use ``update() `` method.
131
+
132
+ .. code-block :: python
133
+
134
+ from google.cloud.firestore import DELETE_FIELD
135
+ data = {
136
+ ' prequel' : DELETE_FIELD
137
+ }
138
+
139
+ fsdb.collection(' Marvels' ).document(' Movies' ).update(data)
140
+ ..
141
+
142
+
143
+
144
+ To remove an item to an array field in an existing document, use
145
+ ``update() `` method.
146
+
147
+ .. code-block :: python
148
+
149
+ from google.cloud.firestore import ArrayRemove
150
+ data = {
151
+ ' cast' : ArrayRemove([' Terrence Howard' ])
152
+ }
153
+
154
+ fsdb.collection(' Marvels' ).document(' Movies' ).update(data)
155
+ ..
156
+
157
+
158
+
108
159
To remove an existing document in a collection, use ``delete() ``
109
160
method.
110
161
0 commit comments