Xbasic
firestore_addDocument Function
IN THIS PAGE
Syntax
p firestore_addDocument(c serviceAccountConnectionString, c collection, c JSON [, c key])
Arguments
- serviceAccountConnectionString
Named Firestore service account connection string.
- collection
Name of the collection. Created automatically if it does not exist.
- JSON
JSON document to add.
- key
(Optional) Document ID. If omitted, a GUID is generated.
Returns
- resultPointer
Properties: error (.t./.f.), errorText (if error), key (inserted document ID).
Description
Adds a new document to a Firestore collection.
Example
' create a new document with an id of "Smith" in a collection called "newCollection"
dim p as p
p.firstName = "Fred"
p.lastName = "Smith"
dim json as c
json = json_generate(p)
dim pr as p
pr = firestore_addDocument("::name::my_fs_connString","newCollection",json,"Smith")Example (optional: result handling - helps verify success and see the returned key.)
if pr.error then
? pr.errorText
else
? "Inserted key: " + pr.key
end if