Xbasic

firestore_query Function

Syntax

p firestore_query(c serviceAccountConnectionString, c collection [, c queryDefinition [, N offset [, N limit]]])

Arguments

serviceAccountConnectionString

Named Firestore service account connection string.

collection

Collection to query.

queryDefinition

CRLF-delimited clauses using operators: (==), (!=), (>), (>=), (<), (<=), (in), (not-in), (array-contains), (array-contains-any). Only one of in/not-in/array-contains-any per query. Clauses are ANDed.

offset

Starting document index (default 0). If 0, the result object includes a count of matching documents.

limit

Maximum number of documents to return.

Returns

resultPointer

error, errorText, and result (array of documents).

Description

Query a collection with optional filters, offset, and limit. Returns a list of matching documents.

Example

' Find all documents where the City is London
City (==) London

' Find all documents where the City is London or Paris
City (in) London,Paris

' Find all documents where the City is Paris and the Country is USA
City (==) Paris
Country (==) USA

Example (optional: run equality)

dim q as c
q = "City (==) London"
dim r as p
r = firestore_query("::name::my_fs_connString","customers",q,0,50)
if r.error then
    ? r.errorText
else
    ? "Returned: " + alltrim(str(len(r.result))) + " documents"
end if

Example (optional: run IN list)

dim q as c
q = "City (in) London,Paris"
dim r as p
r = firestore_query("::name::my_fs_connString","customers",q)
if r.error then ? r.errorText