Firestore Query Subcollection

Hi everybody.

How to create a query on subcollection on firestore.

It’s doesn’t works…

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Could you share your workflow JSON? What have you tried so far and what error are you getting?



When I make the request it returns the date, which means that I have no element found, but I do have an element, with this filter.

I tried reproducing this but I’m able to get the data:

My query:

{
  "structuredQuery": {
    "from": [
      {
        "collectionId": "lead"
      }
    ],
    "limit": 1,
    "where": {
      "fieldFilter": {
        "field": {
          "fieldPath": "userPhoneNumber"
        },
        "op": "EQUAL",
        "value": {
          "stringValue": "+33756851745"
        }
      }
    }
  }
}

and the output:

Maybe something is wrong with your Firestore rules? Have you tried in test mode? For example, these are my rules:

rules_version = '2';

service cloud.firestore {
  match /databases/{database}/documents {

    // This rule allows anyone with your Firestore database reference to view, edit,
    // and delete all data in your Firestore database. It is useful for getting
    // started, but it is configured to expire after 30 days because it
    // leaves your app open to attackers. At that time, all client
    // requests to your Firestore database will be denied.
    //
    // Make sure to write security rules for your app before that time, or else
    // all client requests to your Firestore database will be denied until you Update
    // your rules
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2025, 4, 1);
    }
  }
}

The rules are good because it’s works in http, i try to query a subcollection, not a collection!
thanks for answer

You’re right, looks like querying for sub-collections (no matter what options we choose in the node) does not work.

I filed an issue here: Firestore node sub-collection query returns no data · Issue #13623 · n8n-io/n8n

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.