【发布时间】:2020-03-10 16:53:00
【问题描述】:
在我的 Cloud Firestore 数据库中,我有一组文档,包括创建的时间戳。
Env.docRef.collection('collect').add({
name: this.name,
active: true,
created: firebase.firestore.FieldValue.serverTimestamp()
}).then(function(docRef) {
......;
}.bind(this));
当我需要更新/禁用一个文档时,我想创建一个持续时间字段来表示自文档创建以来的时间。
Env.docRef.collection('collect').doc(this.id).update({
active: false,
ended: firebase.firestore.FieldValue.serverTimestamp(),
duration : ???
}).then(function() {
....;
})
.catch(function(error) {
....;
});
是否有任何选项可以在查询中构建此持续时间?
【问题讨论】:
标签: javascript firebase google-cloud-firestore