Skip to content

feat(firestore): Add timestamp expressions#7826

Merged
yvonnep165 merged 11 commits intomainfrom
yvonne/timestamp-expressions
Mar 26, 2026
Merged

feat(firestore): Add timestamp expressions#7826
yvonnep165 merged 11 commits intomainfrom
yvonne/timestamp-expressions

Conversation

@yvonnep165
Copy link
Copy Markdown
Contributor

Add new timestamp expressions timestamp_diff and timestamp_extract and integration tests for the expressions

The expression timestamp_trunc was already ported in the repo with integration tests. Amend the example usage documentation for standalone methods.

Ported from firebase/firebase-js-sdk#9728

@yvonnep165 yvonnep165 requested a review from a team as a code owner March 19, 2026 18:20
@product-auto-label product-auto-label Bot added the api: firestore Issues related to the Firestore API. label Mar 19, 2026
@yvonnep165 yvonnep165 requested review from dlarocque and milaGGL March 19, 2026 18:21
Comment thread handwritten/firestore/dev/src/pipelines/expression.ts
Comment thread handwritten/firestore/dev/src/pipelines/expression.ts
Comment thread handwritten/firestore/dev/src/pipelines/expression.ts
@dlarocque dlarocque self-requested a review March 26, 2026 15:34
timestampAdd(unit: Expression, amount: Expression): FunctionExpression;
timestampAdd(unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day', amount: number): FunctionExpression;
timestampDiff(start: Expression, unit: Expression): FunctionExpression;
timestampDiff(start: string | Expression, unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day'): FunctionExpression;
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.

I assume this is going to be replaced by the new types u r refactoring.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes it will be changed by that

* field("endTime").timestampDiff("startTime", "day");
* ```
*
* @param start - The field name of the starting timestamp.
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.

the param description doesn't match the type "string | Expression".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh good catch! Changed!

* @example
* ```typescript
* // Calculate the difference in days between 'endTime' field and a starting timestamp expression.
* timestampDiff('endTime', field('startTime'), 'day')
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.

putting the "end" first, "start" the second, this param order feels bit weird. But, since backend proto ordered the params like this + examples are documented, should be fine.

Copy link
Copy Markdown
Contributor

@milaGGL milaGGL left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments

@yvonnep165 yvonnep165 merged commit deeb265 into main Mar 26, 2026
34 of 35 checks passed
@yvonnep165 yvonnep165 deleted the yvonne/timestamp-expressions branch March 26, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the Firestore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants