Firestore
Read and write Google Cloud Firestore documents and run structured queries, with a service account or the emulator. Typical uses: read a mobile or web app's data, load rows into a collection.
firestore putfirestore putfirestore getfirestore getfirestore addfirestore insertfirestore insertfirestore findfirestore findfirestore query_structuredfirestore query_structuredfirestore countfirestore countfirestore updatefirestore updatefirestore batchfirestore deletefirestore delete_wherefirestore collections

firestore put <config> <collection> <id> <json_doc>


Description

    Create or replace a document by id: the document

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    id:   The document id (no /) - String - required
    json_doc:   The document as a JSON object - String - required
admin
firestore put "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "c1" "{\"name\": \"Zoé\", \"city\": \"Paris\", \"age\": 31, \"tags\": [\"vip\"], \"since\": {\"$timestamp\": \"2024-03-01T10:00:00Z\"}}"
mentdb
{"_id": "c1", "name": "Zoé", "city": "Paris", "age": 31, "tags": ["vip"], "since": "2024-03-01T10:00:00Z"}

firestore put <config> <collection> <id> <json_doc> <json_options>


Description

    Put with options: merge (true: only the given top-level fields are written)

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    id:   The document id (no /) - String - required
    json_doc:   The document as a JSON object - String - required
    json_options:   The options - String - required
admin
firestore put "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "c1" "{\"age\": 32}" "{\"merge\": true}"
mentdb
{"_id": "c1", "name": "Zoé", "city": "Paris", "tags": ["vip"], "since": "2024-03-01T10:00:00Z", "age": 32}

firestore get <config> <collection> <id>


Description

    A document as a JSON object with _id first; null if it does not exist

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    id:   The document id (no /) - String - required
admin
firestore get "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "c1"
mentdb
{"_id": "c1", "name": "Zoé", "city": "Paris", "tags": ["vip"], "since": "2024-03-01T10:00:00Z", "age": 32}
no such document (fixed result: real Firestore emulator 1.19.7)
admin
firestore get "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "nothing"
mentdb
null

firestore get <config> <collection> <id> <json_options>


Description

    A document with options: metadata (true: _path, _create_time, _update_time)

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    id:   The document id (no /) - String - required
    json_options:   The options - String - required
admin
firestore get "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "c1" "{\"metadata\": true}"
mentdb
{"_id": "c1", "_path": "customers/c1", "_create_time": "2026-11-17T11:48:10.531911Z", "_update_time": "2026-11-17T11:48:10.535149Z", "name": "Zoé", "city": "Paris", "tags": ["vip"], "since": "2024-03-01T10:00:00Z", "age": 32}

firestore add <config> <collection> <json_doc>


Description

    A new document with an id made by Firestore: the document

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_doc:   The document as a JSON object - String - required
admin
firestore add "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers/c1/orders" "{\"total\": 99.9, \"customer\": {\"$ref\": \"customers/c1\"}}"
mentdb
{"_id": "yl1tlc0mPCScBSae3jAU", "total": 99.9, "customer": "customers/c1"}

firestore insert <config> <collection> <json_rows>


Description

    Insert rows by commits of 500 (each commit is atomic): a _id field gives the id, else a random id of 20 characters: {inserted, errors, ids}

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_rows:   The rows: a JSON array of objects (100000 at most) - String - required
admin
firestore insert "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "[{\"_id\": \"c2\", \"name\": \"Paul\", \"city\": \"Paris\", \"age\": 45}, {\"_id\": \"c3\", \"name\": \"Ana\", \"city\": \"Nice\", \"age\": 19}]"
mentdb
{"inserted": 2, "errors": [], "ids": ["c2", "c3"]}

firestore insert <config> <collection> <json_rows> <json_options>


Description

    Insert with options: id_field (a field copied to the id, it stays in the document), merge, batch_size (500)

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_rows:   The rows: a JSON array of objects (100000 at most) - String - required
    json_options:   The options - String - required
admin
firestore insert "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "[{\"code\": \"c4\", \"name\": \"Max\", \"city\": \"Lyon\", \"age\": 52}]" "{\"id_field\": \"code\"}"
mentdb
{"inserted": 1, "errors": [], "ids": ["c4"]}

firestore find <config> <collection> <json_filter>


Description

    The documents matching a filter (runQuery) as rows, 1000 at most

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_filter:   The filter, the same for every NoSQL family: {"city": "Paris", "age": {"$gte": 18}}; operators $eq $ne $gt $gte $lt $lte $in $nin; the conditions are combined with AND - String - required
admin
firestore find "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"city\": {\"$in\": [\"Nice\", \"Lyon\"]}}"
mentdb
[{"_id": "c3", "name": "Ana", "city": "Nice", "age": 19}, {"_id": "c4", "code": "c4", "name": "Max", "city": "Lyon", "age": 52}]

firestore find <config> <collection> <json_filter> <json_options>


Description

    Find with options: Options: limit (1000, 100000 at most), skip, sort ({"age": -1} or [["age", "desc"]]), fields (an array of field names), metadata, all_descendants (true: every collection of this name, a collection group)

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_filter:   The filter, the same for every NoSQL family: {"city": "Paris", "age": {"$gte": 18}}; operators $eq $ne $gt $gte $lt $lte $in $nin; the conditions are combined with AND - String - required
    json_options:   The options - String - required
admin
firestore find "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"age\": {\"$gte\": 20}}" "{\"sort\": {\"age\": -1}, \"fields\": [\"name\", \"age\"]}"
mentdb
[{"_id": "c4", "name": "Max", "age": 52}, {"_id": "c2", "name": "Paul", "age": 45}, {"_id": "c1", "name": "Zoé", "age": 32}]
by document id (fixed result: real Firestore emulator 1.19.7)
admin
firestore find "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"_id\": {\"$in\": [\"c1\", \"c2\"]}}" "{\"fields\": [\"name\"]}"
mentdb
[{"_id": "c1", "name": "Zoé"}, {"_id": "c2", "name": "Paul"}]
a collection group (fixed result: real Firestore emulator 1.19.7)
admin
firestore find "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "orders" "{}" "{\"all_descendants\": true}"
mentdb
[{"_id": "yl1tlc0mPCScBSae3jAU", "total": 99.9, "customer": "customers/c1"}]

firestore query_structured <config> <collection> <json_structured_query>


Description

    A raw structuredQuery of the REST API (where, orderBy, select, startAt...): the documents as rows. from is the collection when absent

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_structured_query:   The structuredQuery - String - required
admin
firestore query_structured "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"where\": {\"fieldFilter\": {\"field\": {\"fieldPath\": \"age\"}, \"op\": \"LESS_THAN\", \"value\": {\"integerValue\": \"40\"}}}}"
mentdb
[{"_id": "c3", "name": "Ana", "city": "Nice", "age": 19}, {"_id": "c1", "name": "Zoé", "city": "Paris", "tags": ["vip"], "since": "2024-03-01T10:00:00Z", "age": 32}]

firestore query_structured <config> <collection> <json_structured_query> <json_options>


Description

    A raw structuredQuery with options: limit (1000), metadata

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_structured_query:   The structuredQuery - String - required
    json_options:   The options - String - required
admin
firestore query_structured "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"orderBy\": [{\"field\": {\"fieldPath\": \"age\"}, \"direction\": \"ASCENDING\"}]}" "{\"limit\": 1}"
mentdb
[{"_id": "c3", "name": "Ana", "city": "Nice", "age": 19}]

firestore count <config> <collection>


Description

    The number of documents of a collection (aggregation COUNT on the server)

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
admin
firestore count "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers"
mentdb
4

firestore count <config> <collection> <json_filter>


Description

    The number of documents matching a filter

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_filter:   The filter, the same for every NoSQL family: {"city": "Paris", "age": {"$gte": 18}}; operators $eq $ne $gt $gte $lt $lte $in $nin; the conditions are combined with AND - String - required
admin
firestore count "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"city\": \"Paris\"}"
mentdb
2

firestore update <config> <collection> <json_filter> <json_changes>


Description

    Set top-level fields in the matching documents (commits of 500 with an exists precondition): {matched, modified}

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_filter:   The filter, the same for every NoSQL family: {"city": "Paris", "age": {"$gte": 18}}; operators $eq $ne $gt $gte $lt $lte $in $nin; the conditions are combined with AND - String - required
    json_changes:   The new values of top-level fields, like {"vip": true} - String - required
admin
firestore update "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"city\": \"Paris\"}" "{\"vip\": true}"
mentdb
{"matched": 2, "modified": 2}

firestore update <config> <collection> <json_filter> <json_changes> <json_options>


Description

    Update with options: limit (100000)

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_filter:   The filter, the same for every NoSQL family: {"city": "Paris", "age": {"$gte": 18}}; operators $eq $ne $gt $gte $lt $lte $in $nin; the conditions are combined with AND - String - required
    json_changes:   The new values of top-level fields, like {"vip": true} - String - required
    json_options:   The options - String - required
admin
firestore update "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"age\": {\"$gt\": 40}}" "{\"senior\": true}" "{\"limit\": 1}"
mentdb
{"matched": 1, "modified": 1}

firestore batch <config> <json_writes>


Description

    An atomic batch of 500 writes at most: [{op: set|merge|create|update|delete, path, data}]: {writes, commit_time}

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    json_writes:   The writes - String - required
admin
firestore batch "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "[{\"op\": \"set\", \"path\": \"customers/c5\", \"data\": {\"name\": \"Léa\", \"city\": \"Nice\"}}, {\"op\": \"update\", \"path\": \"customers/c4\", \"data\": {\"age\": 53}}, {\"op\": \"delete\", \"path\": \"customers/c3\"}]"
mentdb
{"writes": 3, "commit_time": "2026-11-17T11:48:10.592161Z"}

firestore delete <config> <collection> <id>


Description

    Delete a document: {deleted: 1}, or {deleted: 0} if it does not exist

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    id:   The document id (no /) - String - required
admin
firestore delete "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "c5"
mentdb
{"deleted": 0}

firestore delete_where <config> <collection> <json_filter>


Description

    Delete the documents matching a filter: {deleted}

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
    collection:   The collection path: users, or users/u1/orders for a subcollection - String - required
    json_filter:   The filter, the same for every NoSQL family: {"city": "Paris", "age": {"$gte": 18}}; operators $eq $ne $gt $gte $lt $lte $in $nin; the conditions are combined with AND - String - required
admin
firestore delete_where "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}" "customers" "{\"senior\": true}"
mentdb
{"deleted": 1}

firestore collections <config>


Description

    The collections at the root of the database

Parameters

    config:   The Firestore configuration as JSON, one of: credentials_file (a service account JSON key: a JWT signed with RS256 is exchanged for an OAuth token, kept until 5 minutes before its end), access_token (the name of a secret: secret set), emulator_host (host:port of the local emulator, no authentication). Also project_id (required, else the one of the credentials file), database ((default)), url (https://firestore.googleapis.com), timeout_ms (30000), max_bytes (64 MB) - String - required
admin
firestore collections "{\"emulator_host\": \"127.0.0.1:8080\", \"project_id\": \"demo-shop\"}"
mentdb
["customers"]