类型'CollectionReference'功能云上不存在属性'文档'

问题描述 投票:0回答:1

我试图在触发测试功能时更新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.
firebase google-cloud-functions
1个回答
0
投票

collection()返回firebase.firestore.CollectionReference并且在类CollectionReference内部没有称为document()的方法,这就是你得到错误的原因。

© www.soinside.com 2019 - 2024. All rights reserved.