gpt4 book ai didi

javascript - 无法部署 Firestore Cloud Function

转载 作者:行者123 更新时间:2023-11-30 09:17:07 25 4
gpt4 key购买 nike

我正在尝试在 Firebase Cloud Functions 上部署一个简单的函数,但控制台记录了一个错误,我无法弄清楚它在哪里

我的 index.js:

const functions = require('firebase-functions');
const admin = require('firebase-admin')
admin.initializeApp()

exports.updateAccount = functions.firestore.document('accounts/{client_id}/movements').onWrite(change => {
const document = change.after.exists ? change.after.data() : null
console.log(document)
})

控制台说:

⚠  functions: failed to create function updateAccount
HTTP Error: 400, The request has errors


Functions deploy had errors with the following functions:
updateAccount


To try redeploying those functions, run:
firebase deploy --only functions:updateAccount


To continue deploying other features (such as database), run:
firebase deploy --except functions

Error: Functions did not deploy properly.

最佳答案

您的云函数参数始终指向文档级别,而不是集合级别。

exports.updateAccount = functions.firestore
.document('accounts/{client_id}/movements/{movement_id}')
.onWrite(change => {
const document = change.after.exists ? change.after.data() : null
console.log(document)
})

您正在尝试在集合级别而非文档级别进行部署。

关于javascript - 无法部署 Firestore Cloud Function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54309711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com