Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --output option to firestore:indexes command #8010

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aalej
Copy link
Contributor

@aalej aalej commented Nov 29, 2024

Description

Add --output option to firestore:indexes command. When the --output is passed, it writes the indexes output to the specified filename, if no filename is specified, it will get the filename from firebase.json based on the db name passed from --database.

Scenarios Tested

Given the ff files:

firebase.json
{
  "firestore": [
    {
      "database": "(default)",
      "rules": "firestore.rules",
      "indexes": "firestore.indexes.json"
    },
    {
      "database": "non-default",
      "rules": "firestore-non-default.rules",
      "indexes": "firestore-indexes-non-default.indexes.json"
    }
  ]
}
firestore-indexes-non-default.indexes.json
{
  "indexes": [],
  "fieldOverrides": []
}
firestore.indexes.json
{
  "indexes": [],
  "fieldOverrides": []
}

Sample Commands

firebase firestore:indexes --output Updates firestore.indexes.json

{
  "indexes": [
    {
      "collectionGroup": "messagespaces",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "userIds",
          "arrayConfig": "CONTAINS"
        },
        {
          "fieldPath": "updatedAt",
          "order": "ASCENDING"
        }
      ]
    }
  ],
  "fieldOverrides": []
}

firebase firestore:indexes --output --database non-default Updates firestore-indexes-non-default.indexes.json

{
  "indexes": [
    {
      "collectionGroup": "random-collection",
      "queryScope": "COLLECTION_GROUP",
      "fields": [
        {
          "fieldPath": "a",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "b",
          "order": "DESCENDING"
        }
      ]
    }
  ],
  "fieldOverrides": []
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant