Firestore JSON Where Query "And-Condition"

Hi @Userply, welcome to the community :tada:

You can use Firestore’s CompositeFilter for the job. If you are searching for a document with first_name = Patrick and last_name = Star, the JSON query could look like below.

Document:

image

Query:

{
  "structuredQuery": {
    "where": {
      "compositeFilter": {
        "op": "AND",
        "filters": [{
          "fieldFilter": {
            "field": {
              "fieldPath": "first_name"
            },
            "op": "EQUAL",
            "value": {
              "stringValue": "Patrick"
            }
          }
        }, {
          "fieldFilter": {
            "field": {
              "fieldPath": "last_name"
            },
            "op": "EQUAL",
            "value": {
              "stringValue": "Star"
            }
          }
        }]
      }
    },
    "from": [{
      "collectionId": "demo"
    }]
  }
}

In an n8n workflow using expressions this could look like so:

This is the result:

Hope this helps!

1 Like