Xbasic

firestore_bulkImportDocuments Function

Syntax

p firestore_bulkImportDocuments(c serviceAccountConnectionString, c collection, c JSON [, c idProperty])

Arguments

serviceAccountConnectionString

Named Firestore service account connection string.

collection

Destination collection (created if missing).

JSON

Either (1) a JSON array of documents, or (2) a JSON object describing a SQL import: { "connectionString":"MySQLConn", "sql":"select EmployeeId as id, Lastname from Employees", "argumentsXML":"" }

idProperty

Optional property in each JSON item that should be used as the document ID.

Returns

resultPointer

error, errorText, and a JSON list of inserted keys.

Description

Import multiple documents into a Firestore collection from a JSON array or a SQL query descriptor.

Example

dim pp as p
pp.connectionstring = "AADemo-Northwind"
pp.sql = "select EmployeeId as id, Lastname from Employees"
pp.argumentsXML = ""
dim json as c
json = json_generate(pp)
' this JSON can be passed into the firestore_buldImportDocuments() function

Example (Optional: end-to-end call showing success/error flow after building the SQL descriptor)

dim r as p
r = firestore_bulkImportDocuments("::name::my_fs_connString","employees",json)
if r.error then
    ? r.errorText
else
    ? json_reformat(r.result)
end if