简体   繁体   English

更新服务器时间戳 - firestore

[英]Update Server time stamp - firestore

I am new to using firestore and would greatly appreciate an answer.我是使用 firestore 的新手,非常感谢您的回答。

I am updating the documents in my firestore with a timestamp.我正在使用时间戳更新我的 Firestore 中的文档。 Will that timestamp represent the time that document was originally created, or does the timestamp represent the time that i updated it?该时间戳是代表文档最初创建的时间,还是代表我更新文档的时间?

It just depends on whether you update that field in particular or not.这仅取决于您是否特别更新该字段。

If you update the field containing the timestamp on each write then it will represent that update time.如果您在每次写入时更新包含时间戳的字段,那么它将代表该更新时间。 You don't mention it but if you work with AngularFire, you can make sure the timestamp gets updated on each write if your update is something like this:你没有提到它,但如果你使用 AngularFire,你可以确保时间戳在每次写入时得到更新,如果你的更新是这样的:

.doc('user/' + user.id).update({
      someValue: "someValue",
      date: firebase.default.firestore.FieldValue.serverTimestamp()
    })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM