Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: no entity to update: app - Firestore Cloud Function

This is my very basic Cloud Function:

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

exports.createdNewAccount = functions.auth.user().onCreate(event => {
    return db.collection('users').doc(event.data.uid).update({
        "creationDate" : Date.now()
    })
})

And I get the error

Error: no entity to update: app

What is wrong with my code?

like image 887
J. Doe Avatar asked Oct 10 '17 21:10

J. Doe


1 Answers

Most likely, the document for event.data.uid does not exist. The documentation for update() states:

The update will fail if applied to a document that does not exist.

Use set() instead.

like image 101
Bob Snyder Avatar answered Oct 19 '22 16:10

Bob Snyder