Timestamps
There are two types of timestamps we use when writing data in the Collaboration system:
- Current timestamps - these are timestamps that represent the "current time". These timestamps are used for properties such as
createdAt
,updatedAt
, etc. - Past timestamps - these timestamps represent dates and times in the past.
#
Current timestampsBy default, current timestamps are set to CURRENT_TIMESTAMP
, which is a constant value that sets that column equal to the current time in most SQL databases.
This is configurable by passing a getNow
function to the Collab Server constructor.
The getNow
function accepts no parameters and must return a representation of 'now' for your database. By default, we use the value CURRENT_TIMESTAMP
.
Whatever value is returned from this function will be passed into your resolvers for any current timestamps.
The following entity properties are always set to the current time:
createdAt
updatedAt
lastRead
#
ExamplesPostgreSQL NOW()
:
#
Past timestampsAll timestamps with a known value (in the past) will be passed as a unix timestamp in MS.
In these scenarios, you will need to transform this timestamp into your databases format.
Right now, there is only one scenario where this use case happens:
- Creating an AnnotationMember
AnnotationMember.annotationCreatedAt
is passed as a unix timestamp in MS