Cloud Firestore

Firebase.firestore_batchget — Method

firestore_batchget(batch)

Gets multiple documents. batch is a BatchGetDocumentsRequest body, e.g. Dict("documents" => ["projects/<id>/databases/(default)/documents/<path>", ...]). Documents returned by this method are not guaranteed to be returned in the same order that they were requested.

Example

init("[FIREBASE_ADMIN_SDK].json")
pid = projectid()
res = firestore_batchget(Dict("documents" => [
    "projects/$pid/databases/(default)/documents/users/alice",
]))
source
Firebase.firestore_batchwrite — Method

firestore_batchwrite(batch)

Applies a batch of write operations. The documents.batchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write.

If you require an atomically applied set of writes, use documents.commit instead.

Example

init("[FIREBASE_ADMIN_SDK].json")
pid = projectid()
res = firestore_batchwrite(Dict("writes" => [Dict("update" => Dict(
    "name" => "projects/$pid/databases/(default)/documents/users/alice",
    "fields" => Dict("first" => Dict("stringValue" => "Alice")),
))]))
source
Firebase.firestore_beginTransaction — Method

firestore_beginTransaction()

Starts a new transaction. "options" The options for the transaction. Defaults to a read-write transaction.

Example

init("[FIREBASE_ADMIN_SDK].json")
firestore_beginTransaction()
source
Firebase.firestore_commit — Function

firestore_commit(transactionid="", body=Dict())

Commits a transaction, while optionally applying the writes in body (Dict("writes" => [...])).

Example

init("[FIREBASE_ADMIN_SDK].json")
data = firestore_beginTransaction()
firestore_commit(data["transaction"])
source
Firebase.firestore_createdoc — Function

firestore_createdoc(url, body)

Example

init("[FIREBASE_ADMIN_SDK].json")
firestore_createdoc("/firebase_test/firebase_post/two") 
firestore_createdoc("/firebase_test/firebase_post/three";query ="hello") # with document id name in query
source
Firebase.firestore_deletedoc — Method

firestore_deletedoc(url)

Deletes a document

Example

init("[FIREBASE_ADMIN_SDK].json")
firestore_createdoc("/firebase_test/firebase_post/three";query ="hello") # creates the document and then we delete it
firestore_deletedoc("/firebase_test/firebase_post/three/hello")
source
Firebase.firestore_getcollectionids — Method

firestore_getcollectionids(url; pagesize=300, pagetoken="")

Lists the collection IDs directly underneath the document at url. Returns the raw response: "collectionIds" and, when there are more results, "nextPageToken", which can be passed back as pagetoken to fetch the next page.

Example

init("[FIREBASE_ADMIN_SDK].json")
firestore_getcollectionids("/firebase_test/firebase_post")
source
Firebase.firestore_partitionquery — Function

firestore_partitionquery(url)

Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by documents.runQuery as starting/end points for the query results.

source
Firebase.firestore_patch — Function

firestore_patch()

Updates or inserts a document.

Example

init("[FIREBASE_ADMIN_SDK].json")
firestore_patch("/firebase_test/firebase_patch")
source
Firebase.firestore_runquery — Function

firestore_runquery()

Runs a query.

Example

init("[FIREBASE_ADMIN_SDK].json")
firestore_runquery("/firebase_test/firebase_post")
source
Firebase.get_request — Method

get_request(url::String)

Get request which is general in nature and gets any document or collection

Example

init("[FIREBASE_ADMIN_SDK].json")
res = get_request("/firebase_test/firebase_get") # document get
res = get_request("/firebase_test/firebase_get/firebase_get_collection") # collection fetch
source