我试图在触发测试功能时更新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/[email protected] (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.
collection()
返回firebase.firestore.CollectionReference
并且在类CollectionReference
内部没有称为document()
的方法,这就是你得到错误的原因。