0

FaunaDB's At() function looks so nice! I wonder if I can log a time series of sensor data into one document, and draw a time series chart by At() function and change history of the document.

So, is there any way to get a change history of FaunaDB's documents? Thank you for your suggestion!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ueda Takeyuki
  • 721
  • 10
  • 26

1 Answers1

4

Events($ref) will give you the history of a document. The amount of retained history is configurable. The complete docs for Event is found here.

That said I'm not sure I'd choose to implement a sensor time series that way. I'd be more inclined to write a separate document per reading. Mostly because it's easier to work with first class values for time series and if you need to record quickly you won't run into conflicts.

benjumanji
  • 1,395
  • 7
  • 15
  • Thank you for your quick answer, function Events($ref) works perfectly! Also thank you for your kindly suggestion, so typical usage of history might be a rollback of data? – Ueda Takeyuki Feb 23 '20 at 13:59
  • 1
    Rollback is definitely a strong usecase, audit is another. Lots of reasons to browse history. A top level bank balance might be a fun one to look at the history of, but I'd still store the transactions separately. – benjumanji Feb 23 '20 at 22:23