关于云功能,如果我更新交易中的某些文档, 更新会在承诺结论之后立即发生吗?
我正在应用程序中测试此行为:有时,当我在文档上使用简单的get(没有持久性)时,在云功能(更新文档)结束后,文档不会立即更新。
打字稿中可调用的云函数示例:
exports.cloudFunctionExample = functions.https.onCall(async (data, context) => {
await admin.firestore().runTransaction(async (transaction: Transaction) => {
const docExample: DocumentSnapshot = await transaction.get('colllectionExample/docExample');
await transaction.update(docExample.ref, {"newKey": "newValue"})
});
return null;
});
Dart应用程序示例:
HttpsCallable functionCallable = CloudFunctions().getHttpsCallable(
functionName: 'cloudFunctionExample',
);
await functionCallable.call();
DocumentSnapshot docExample = await Firestore().document('colllectionExample/docExample').get(source: Source.server);
if (docExample.data["newKey"] != "newValue")
throw AssertionError();
这是预期的行为吗?在Firestore中更新文档时,交易会有延迟吗?