Skip to content

feat(firestore): Add logical expressions#9702

Merged
milaGGL merged 6 commits intomainfrom
mila/expressions-logical
Mar 25, 2026
Merged

feat(firestore): Add logical expressions#9702
milaGGL merged 6 commits intomainfrom
mila/expressions-logical

Conversation

@milaGGL
Copy link
Copy Markdown
Contributor

@milaGGL milaGGL commented Mar 9, 2026

Add new logical expressions nor and switchOn.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: 7670995

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
firebase Minor
@firebase/firestore Minor
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the logical expression capabilities within Firestore by introducing nor and switchOn. These new functions empower developers to construct more sophisticated and readable conditional logic directly within their database operations. The nor expression simplifies scenarios requiring the negation of multiple conditions, while switchOn offers a powerful and concise way to handle multi-case conditional evaluations, improving code clarity and reducing complexity for advanced querying and data manipulation patterns.

Highlights

  • New Logical Expressions: Implemented nor logical expression for Firestore, allowing checks where all specified conditions are false.
  • New Conditional Expression: Introduced switchOn logical expression for Firestore, providing a flexible conditional evaluation mechanism similar to a switch statement.
  • API and Documentation Updates: Updated API definitions and documentation across Firestore and Firestore Lite to include the new logical expressions.
  • Test Coverage: Added comprehensive integration and unit tests to validate the functionality of nor and switchOn.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .changeset/orange-worms-juggle.md
    • Added a new changeset file to document the feature addition.
  • common/api-review/firestore-lite-pipelines.api.md
    • Added nor and switchOn function declarations to the Firestore Lite API review file.
  • common/api-review/firestore-pipelines.api.md
    • Added nor and switchOn function declarations to the main Firestore API review file.
  • docs-devsite/firestore_lite_pipelines.md
    • Updated Firestore Lite documentation to include nor and switchOn with examples.
  • docs-devsite/firestore_pipelines.md
    • Updated main Firestore documentation to include nor and switchOn with examples.
  • packages/firestore/lite/pipelines/pipelines.ts
    • Exported the new nor and switchOn functions.
  • packages/firestore/src/api_pipelines.ts
    • Exported the new nor and switchOn functions and adjusted the order of existing exports.
  • packages/firestore/src/lite-api/expressions.ts
    • Implemented the nor and switchOn logical expression functions.
  • packages/firestore/test/integration/api/pipeline.test.ts
    • Added integration tests for nor and switchOn expressions.
  • packages/firestore/test/lite/pipeline.test.ts
    • Added unit tests for nor and switchOn expressions.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces nor and switchOn logical expressions, enhancing the Firestore query capabilities. The implementation and tests look good. I've found a few minor inconsistencies in the documentation that should be addressed for clarity.

Comment thread docs-devsite/firestore_lite_pipelines.md Outdated
Comment thread docs-devsite/firestore_pipelines.md Outdated
Comment thread packages/firestore/src/lite-api/expressions.ts Outdated
@milaGGL milaGGL marked this pull request as ready for review March 11, 2026 14:30
@milaGGL milaGGL requested review from a team as code owners March 11, 2026 14:30
],
'switchOn'
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to only have standalone functions for these two expressions. But still just want to confirm that we don't need to have pipeline chain functions for these two expressions right? like .nor(...)

Copy link
Copy Markdown
Contributor Author

@milaGGL milaGGL Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is not quite readable to have instance methods for nor , just like or,xor. As for switchOn, it takes multiple conditions, which are independent of each other. so, we cannot do sth like field("count").switchOn(equalTo(1),"one", equalTo(2), "two",...) . it is going to be more like this field("count").switchOn(equalTo(1),"one", field("count").equalTo(2), "two",...), which is confusing

Copy link
Copy Markdown
Contributor

@yvonnep165 yvonnep165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@milaGGL milaGGL merged commit 44ad4cc into main Mar 25, 2026
43 of 44 checks passed
@milaGGL milaGGL deleted the mila/expressions-logical branch March 25, 2026 15:56
@google-oss-bot google-oss-bot mentioned this pull request Apr 8, 2026
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.

4 participants