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

Query snapshots from UTC datetime #1019

Closed
nickshoe opened this issue Sep 11, 2020 · 3 comments
Closed

Query snapshots from UTC datetime #1019

nickshoe opened this issue Sep 11, 2020 · 3 comments

Comments

@nickshoe
Copy link
Contributor

I need to retrieve from the DB all the snapshots of a given class, starting from a given point in time. My application stores dates according to UTC, as it is much simpler to handle when it comes to i18n and i10n.

At the moment, its not possible to query for snapshot from a given UTC datetime, but only from a local datetime.

The only way of doing this is by "fooling" the query builder, by first converting an UTC datetime into a local datetime. I consider this rather an hack.

Apparently, Javers already stores the UTC datetime commit_date_instant in the jv_commit table.
(I don't know why, but the microseconds part sometimes differs between the two dates)
image

Describe the solution you'd like
An additional fromUTC or fromInsant or from(Instant ...) method that takes UTC datetime (Instant) would solve my problem.

Additional context
I'm taking advantage of JaVers for exposing a Data Synchronization API in my application. In this context, the third party system needs to ask all the changes that have occured since the latest commit read in the previous interaction. The majority of REST API uses ISO8601 UTC dates for serializing datetime in the JSON payload.

@nickshoe
Copy link
Contributor Author

For the sake of data synchronization, it would be even better to have the possibility of querying snapshots from a given commit id (excluded) onwards.

@bartoszwalacik
Copy link
Member

fromInsant() would be more natural, since Commit has commitDateInstant persisted. We will accept your PR.

@bartoszwalacik
Copy link
Member

released in 5.12

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

No branches or pull requests

2 participants