我正在尝试在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.
答案 0 :(得分:3)
抱歉重播。
找你云函数参数总是指向文档级别,而不是在集级别
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)
})
您正在尝试在集合级别而不是在文档级别进行部署