fieldValue.Increment(int)不会降低火焰扑来的值
试图降低火灾中的价值。但是以下方法无效。
int fastDur = -20;
void cancelHours() async {
return usersRef.doc(firebaseAuth.currentUser!.uid).collection('posts')
.orderBy('datePublished', descending: true)
.limit(1).get().then((querySnapshot) {
return querySnapshot.docs.forEach((element) {
usersRef
.doc(firebaseAuth.currentUser!.uid).collection('posts')
.doc(element.reference.id)
.update({"totalTime": FieldValue.increment(fastDur)});
});
});
}
但是,如果我将'-20'放在方法fieldValue.increment(-20)中,则可以工作。但是,众所周知,我无法将其进行硬编码,因为FastDur具有用户选择的不同值。请帮忙。
trying to decrement a value in firestore. but the below method does not work.
int fastDur = -20;
void cancelHours() async {
return usersRef.doc(firebaseAuth.currentUser!.uid).collection('posts')
.orderBy('datePublished', descending: true)
.limit(1).get().then((querySnapshot) {
return querySnapshot.docs.forEach((element) {
usersRef
.doc(firebaseAuth.currentUser!.uid).collection('posts')
.doc(element.reference.id)
.update({"totalTime": FieldValue.increment(fastDur)});
});
});
}
however, if I put '-20' into the method FieldValue.increment(-20) then it works. But as you all know, I cannot hardcode it as the fastDur has different values that user chooses. please, help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用firestore buildin询问方法
Use Firestore buildin query method