0

I have a Record.json document stored in Microsoft Azure DocumentDB. I need to be able to store the createTimestamp and lastModifiedTimestamp as additional properties on the json. For every update on the document, it appears the lastModifiedTimestamp has to be manually maintained and updated. Is there an efficient alternative to handle timestamps in DocumentDB?

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
Vamsi Emani
  • 10,072
  • 9
  • 44
  • 71

1 Answers1

2

Is there an efficient alternative to handle timestamps in DocumentDB?

DocumentDB has a system defined attribute called _ts which gets updated every time a resource (document in your case) is updated.

You can use this attribute to track when the document was last updated. Please see this link for more details on system defined attributes: https://learn.microsoft.com/en-us/azure/documentdb/documentdb-resources#system-vs-user-defined-resources.

Please note that _ts is represented as a POSIX or epoch time value. In other words, its the number of seconds (not milliseconds) that have elapsed since 00:00:00 (UTC), 1 January 1970 (Ref: How _ts change in DocumentDB).

Community
  • 1
  • 1
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241