Skip to content

Conversation

@fkwfung
Copy link

@fkwfung fkwfung commented Oct 25, 2025

Description

Fixes #5169

This PR adds support for custom Firestore database IDs when creating composite indexes, enabling users to work with non-default Firestore databases.

Changes

  • Added optional database_id parameter to FirestoreDb.__init__() (positioned after project_id)
  • Updated create_collection_indexes() to accept and pass database_id
  • Modified _create_composite_indexes() to use database_id in the parent_path construction
  • Updated _get_or_create_collection() to pass database_id through

Key Features

  • Backward Compatible: Defaults to "(default)" when not specified
  • Low Risk: All changes are additive with sensible defaults
  • High Value: Enables multi-database Firestore configurations

Testing

The implementation follows the exact specification from issue #5169. All existing cookbook examples continue to work as they use keyword arguments.

Example Usage

# Using default database (existing behavior)
db = FirestoreDb(project_id="my-project")

# Using custom database (new feature)
db = FirestoreDb(
    project_id="my-project",
    database_id="my-custom-db"
)

Checklist

Fixes agno-agi#5169

- Added optional database_id parameter to FirestoreDb.__init__() after project_id
- Updated create_collection_indexes() to accept and pass database_id
- Modified _create_composite_indexes() to use database_id in parent_path
- Updated _get_or_create_collection() to pass database_id through
- Defaults to '(default)' for backward compatibility

This enables users to create composite indexes on non-default Firestore
databases, allowing for multi-database Firestore configurations.

Changes are fully backward compatible as database_id is optional and
existing code using keyword arguments will continue to work.
@fkwfung fkwfung requested a review from a team as a code owner October 25, 2025 00:17
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.

[Feature Request] Accept Database ID in Firestore Composite Index Creation

1 participant