Xbasic
firestore_updateDocument Function
Syntax
p firestore_updateDocument(c serviceAccountConnectionString, c collection, c JSON, c key, [L flagMerge])
Arguments
- serviceAccountConnectionString
Named Firestore service account connection string.
- collection
Collection that contains the document.
- JSON
JSON payload. If flagMerge is .f., replaces the whole document; if .t., merges matching properties.
- key
Document ID to update.
- flagMerge
Optional. .t. to merge, .f. to replace.
Returns
- resultPointer
Has error and errorText (if any).
Description
Update an existing Firestore document.
Example (merge)
dim p as p
p.phone = "617-555-0101"
dim json as c
json = json_generate(p)
dim r as p
r = firestore_updateDocument("::name::my_fs_connString","customers",json,"Smith",.t.)
if r.error then ? r.errorTextExample (optional: replace showing both pathways (merge vs replace))
dim p as p
p.firstName = "Fred"
p.lastName = "Smith"
dim r as p
r = firestore_updateDocument("::name::my_fs_connString","customers",json_generate(p),"Smith",.f.)
if r.error then ? r.errorText