我正在尝试在Firebase Cloud Functions上部署一个简单的函数,但控制台记录了一个错误,我无法弄清楚在哪里
我的索引.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)
})
您正在尝试在集合级别而不是文档级别进行部署。