feat(firestore): Add timestamp expressions#7826
Merged
yvonnep165 merged 11 commits intomainfrom Mar 26, 2026
Merged
Conversation
dlarocque
reviewed
Mar 19, 2026
dlarocque
approved these changes
Mar 26, 2026
milaGGL
reviewed
Mar 26, 2026
| 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; |
Contributor
There was a problem hiding this comment.
I assume this is going to be replaced by the new types u r refactoring.
Contributor
Author
There was a problem hiding this comment.
yes it will be changed by that
milaGGL
reviewed
Mar 26, 2026
| * field("endTime").timestampDiff("startTime", "day"); | ||
| * ``` | ||
| * | ||
| * @param start - The field name of the starting timestamp. |
Contributor
There was a problem hiding this comment.
the param description doesn't match the type "string | Expression".
Contributor
Author
There was a problem hiding this comment.
Oh good catch! Changed!
milaGGL
reviewed
Mar 26, 2026
| * @example | ||
| * ```typescript | ||
| * // Calculate the difference in days between 'endTime' field and a starting timestamp expression. | ||
| * timestampDiff('endTime', field('startTime'), 'day') |
Contributor
There was a problem hiding this comment.
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.
milaGGL
approved these changes
Mar 26, 2026
Contributor
milaGGL
left a comment
There was a problem hiding this comment.
LGTM with minor comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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