如何在Angular中将数据另存为Firestore Timestamp对象 [英] How to save data as Firestore Timestamp object in Angular
本文介绍了如何在Angular中将数据另存为Firestore Timestamp对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只想将Date作为时间戳保存在Firestore数据库中,但它将时间戳存储为数字:
Just want to save Date as timestamp in Firestore database but it's storing timestamp as number:
save() {
const data = this.transactionForm.value;
data.type = data.type == 'true' || data.type == true ? true : false;
data.updated = firebase.firestore.FieldValue.serverTimestamp();
// Date string to timestamp
data.date = new Date(data.date.split("-").reverse().join("-")).getTime();
let id = data.id;
this.transCollection.doc(id).update(data);
}
推荐答案
我在Firebase中使用时间戳,并且我知道它用于将日期存储在数字中的 long
中.所以我不知道Firestore中是否一样.
I use timestamp in Firebase and I know it is use to store date in long
which is number. So I dont know if it is the same in Firestore.
这篇关于如何在Angular中将数据另存为Firestore Timestamp对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文