如何将以前的时间戳保存到Firebase FireStore [英] How to save previous timestamp to Firebase FireStore
本文介绍了如何将以前的时间戳保存到Firebase FireStore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将旧数据从其他系统迁移到Firestore.
I want to migrate the older data from different system to firestore.
下面的命令保存当前时间戳
below command saves current timestamp
firebase.firestore.FieldValue.serverTimestamp()
我想存储较早的值,有什么办法吗?
I want to store older values, Is there any way available?
推荐答案
firebase.firestore.FieldValue.serverTimestamp()
是标记值,您可以在代码中使用该标记值,将当前服务器端时间戳记写入日期字段.如果要在日期字段中存储另一个值,则可以在写入时指定该值.
firebase.firestore.FieldValue.serverTimestamp()
is a marker value you can use in your code to write the current server-side timestamp into a date field. If you want to store another value in a date field, you can specify the value when writing.
摘录自有关添加数据的Firebase文档 :
db.collection("data").doc("one").set({
dateField: new Date("December 10, 1815"),
}).then(function() {
console.log("Document successfully written!");
});
这篇关于如何将以前的时间戳保存到Firebase FireStore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文