How do I provide parameters to the "list documents" step for Firebase Firestore?

Currently, when I try to list documents from firebase, I just can provide the maximum limit but no other filters or query parameters, like sorting or filtering. How do I provide this (and how could I request this be part of the step itself)?

Hi @Timfong888,

To customize your request to list documents from Firebase with additional filters or query parameters such as sorting or filtering, you would typically need to write custom code if the pre-built Pipedream component does not support these features directly. Here’s how you can achieve this using a Node.js code step in Pipedream:

import { axios } from "@pipedream/platform"

export default defineComponent({
  props: {
    firebase: {
      type: "app",
      app: "firebase",
    }
  },
  async run({steps, $}) {
    const projectId = "your-firebase-project-id";
    const databaseId = "(default)"; // or your Firestore database ID
    const collectionId = "your-collection-id";
    
    // Construct Firestore REST API URL
    const url = `https://firestore.googleapis.com/v1/projects/${projectId}/databases/${databaseId}/documents/${collectionId}`;
    
    // Add query parameters for filtering, sorting, etc.
    // This is an example to show structure, replace with your actual query parameters
    const queryParams = {
      orderBy: "fieldName", // Sorting
      // For filtering, Firestore uses StructuredQuery, which you would need to build as per your requirements
      // Refer to Firestore REST API documentation for constructing StructuredQuery
    };
    
    return await axios($, {
      method: "GET",
      url,
      params: queryParams,
      headers: {
        Authorization: `Bearer ${this.firebase.$auth.oauth_access_token}`,
      },
    })
  },
})

Please replace "your-firebase-project-id", "your-collection-id", and the queryParams with your actual Firebase project ID, collection ID, and desired query parameters. Note that Firestore uses a StructuredQuery for filtering, which you would need to construct as per your requirements. Refer to the Firestore REST API documentation for details on constructing a StructuredQuery.

If you believe this functionality should be part of the pre-built Firebase component in Pipedream, you can request this feature by submitting a new integration request. Please visit New Pipedream Integration Request to submit your request.

I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.