如下所示,触发测试功能时,我正在尝试更新Firestore中的文档
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin'
admin.initializeApp(functions.config().firebase);
exports.test = functions.firestore.document('test/{id}').onCreate(event => {
admin.firestore().collection("testcollection").document(data.truckId)
})
但是这行代码不起作用
admin.firestore().collection("testcollection").document()
它给我错误文档功能不存在
编辑
我正在使用以下代码
admin.firestore().doc(`anothercollection/${data.id}`)
.get().then((result)=>{
});
它工作正常,但是在使用以下命令部署功能时
firebase deploy --only functions
我遇到以下错误
Failed to configure trigger providers/cloud.firestore/eventTypes/document.create@firestore.googleapis.com (test)
✔ functions[test(us-central1)]: Successful update operation.
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
答案 0 :(得分:0)
collection()
返回firebase.firestore.CollectionReference
,并且在类CollectionReference
中没有名为document()
的方法,这就是为什么会出错的原因。