Discussion:
Inserting current datetime instant of the database
Christopher Cook
2017-10-11 20:07:18 UTC
Permalink
Hi all,

Is there a function of Datomic that allows an instant field to be set with
the database's current instant? Similar to Postgres' now()?

We have multiple clients that could write the field but they aren't
guaranteed to be time synchronized, so setting with new Date() doesn't fit
our use case.

Thanks,
Chris
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Linus Ericsson
2017-10-11 20:44:42 UTC
Permalink
Yes, you can do it with a transaction function.

However, there is a field db/txInstant in each transaction that is
(usually) set to the transactors monotonicaöly increasing timestamp (or I
really hope it is monotonically increasing enough to not collide).

/Linus

ons 11 okt. 2017 kl. 22:08 skrev Christopher Cook <
Post by Christopher Cook
Hi all,
Is there a function of Datomic that allows an instant field to be set with
the database's current instant? Similar to Postgres' now()?
We have multiple clients that could write the field but they aren't
guaranteed to be time synchronized, so setting with new Date() doesn't fit
our use case.
Thanks,
Chris
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christopher Cook
2017-10-11 21:20:53 UTC
Permalink
When a transaction function is being executed, does the db/txInstant field
exist yet? If so, how is it accessed?
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Linus Ericsson
2017-10-11 23:10:13 UTC
Permalink
No, I dont think so.

But you can access it at query-time. That was what I had in mind.

/Linus

ons 11 okt. 2017 kl. 23:20 skrev Christopher Cook <
Post by Christopher Cook
When a transaction function is being executed, does the db/txInstant field
exist yet? If so, how is it accessed?
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Christopher Cook
2017-10-13 13:01:34 UTC
Permalink
I see what you mean. Just query for the explicit transaction timestamp as
opposed to storing the timestamp in a user field.

Should have known that. Thanks for the reminder.

Chris
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...