Does Cloud Firestore have an audit trail?

╄→尐↘猪︶ㄣ 提交于 2020-06-16 17:59:59

问题


I really like the offering that's Cloud Firestore. But does it have an audit trail?

Why am I asking? While some use of databases is essentially "state" (e.g. multiplayer games), for other uses also the history matters. Also, at times being able to see the history would be useful for debugging purposes (time travel).

So what's the means I would have to ask e.g. "who deleted a value in this document" or "who has touched this doc since its inception"?

Do people use additional commentary documents to do this at the application level, or can I just enable a setting somewhere that would create such a document behind the scene, automatically? (I could then describe access rights just as for any other Firestore document.)

Addons, plugins etc. can also be suggested. I don't have a pressing use case for this right now - just want to understand where Cloud Firestore would fit and where not.


Btw, the Getting to know Cloud Firestore series in Youtube is plain awesome! :)


回答1:


So what's the means I would have to ask e.g. "who deleted a value in this document" or "who has touched this doc since its inception"?

Cloud Firestore dosn't store such metadata. If you find yourself in a position in which you need such details, you'll need to create a mechanism to store them. So in case you want to know who deleted a specific value, you should create an array of objects where you should store the uid of the user who deleted that value and a timestamp.

Do people use additional commentary documents to do this at the application level

Yes, we usually do.

or can I just enable a setting somewhere that would create such a document behind the scene, automatically?

There is no such a setting that can be neabled.

If you need a history version of the document, a possible schema that might help you is in my answer from the following post:

  • Firestore: Version history of documents


来源:https://stackoverflow.com/questions/57461435/does-cloud-firestore-have-an-audit-trail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!