我正在使用来增加值
const increment = firestore.FieldValue.increment(1);
this.fb.afs.collection(colId).doc(docId).set({
invoiceCount: increment
}, {
merge: true
})
在继续使用此值后,如何立即检索增加的值?
在同时访问情况下,以下内容是否足够或重要:
this.fb.afs.collection(colId).doc(docId).set({
count: increment
}, {
merge: true
})
.finally(() => {
this.fb.afs.collection(colId).doc(docId).valueChanges().pipe(first()).subscribe(res => {
//proceed with res.count
})
})
有什么更好的方法?
答案 0 :(得分:1)
更新后,您可以在Firestore文档上调用get
,这将获取您刚刚更新的文档:
"dependencies": {
"nativescript-theme-core": "~1.0.4",
"nativescript-unit-test-runner": "^0.7.0",
"tns-core-modules": "~5.3.0"
},
"devDependencies": {
"@types/karma-chai": "0.1.1",
"@types/mocha": "5.2.6",
"chai": "4.2.0",
"karma": "4.3.0",
"karma-chai": "0.1.0",
"karma-mocha": "1.3.0",
"karma-nativescript-launcher": "0.4.0",
"karma-webpack": "3.0.5",
"mocha": "6.1.4",
"nativescript-dev-typescript": "~0.9.0",
"nativescript-dev-webpack": "~0.21.0"
}