Firebase 财产';文件';不存在于类型';收藏参考';功能云

Firebase 财产';文件';不存在于类型';收藏参考';功能云,firebase,google-cloud-functions,Firebase,Google Cloud Functions,当触发测试功能时,我正在尝试更新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 =

当触发测试功能时,我正在尝试更新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.

返回
firebase.firestore.CollectionReference
,在类中没有名为
document()
的方法,这就是为什么会出现错误。

我理解这一点,但如何访问文档以更新其某些值?请尝试doc()方法。还有
onUpdate()
触发器,而不是
onCreate()
它正在工作,但我现在遇到另一个错误,我编辑了问题remove$from data.idthe$只是一种将变量写入字符串的方法,它与错误无关