javascript - Cannot deploy Firestore Cloud Function - Stack Overflow

I'm trying to deploy a simple function on Firebase Cloud Functions but console logs an error that

I'm trying to deploy a simple function on Firebase Cloud Functions but console logs an error that I can't figure out where is

My 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)
})

Console says:

⚠  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.

I'm trying to deploy a simple function on Firebase Cloud Functions but console logs an error that I can't figure out where is

My 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)
})

Console says:

⚠  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.
Share Improve this question asked Jan 22, 2019 at 13:47 Marcelo J ForclazMarcelo J Forclaz 7281 gold badge9 silver badges30 bronze badges 1
  • If you're having a problem with the Firebase CLI showing unexpected errors, you should reach out to Firebase support directly. firebase.google./support/contact – Doug Stevenson Commented Jan 22, 2019 at 17:11
Add a ment  | 

1 Answer 1

Reset to default 10

Your cloud function argument always points to the document level, not the collection level.

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)
})

You are trying to make the deployment in the collection level, not in the document level.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742299746a4417813.html

相关推荐

  • javascript - Cannot deploy Firestore Cloud Function - Stack Overflow

    I'm trying to deploy a simple function on Firebase Cloud Functions but console logs an error that

    21小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信