firebase / functions-samples

Collection of sample apps showcasing popular use cases using Cloud Functions for Firebase
https://firebase.google.com/docs/functions
Apache License 2.0
12.07k stars 3.84k forks source link

child-count sample has not been updated for v1.0 #399

Open puf opened 6 years ago

puf commented 6 years ago

How to reproduce these conditions

Take the sample function from: https://github.com/firebase/functions-samples/blob/master/child-count/functions/index.js

And try to deploy it on the Cloud Functions for Firebase v1.0 SDK. You'll get this error:

TypeError: Cannot read property 'ref' of undefined at

nicolasgarnier commented 6 years ago

It looks like it's OK. Can you double check you were indeed using the SDK v1 pls?

puf commented 6 years ago

It looks like recountlikes wasn't updated:

https://github.com/firebase/functions-samples/blob/master/child-count/functions/index.js#L47-L49

exports.recountlikes = functions.database.ref('/posts/{postid}/likes_count').onDelete((snap) => {
  const counterRef = snap.ref;
  const collectionRef = counterRef.parent.child('likes');
lovince commented 6 years ago

Experiencing the same. Looks like onCreate() and onDelete() is passing in an event instead of a DataSnapshot?

desduvauchelle commented 4 years ago

Any updates on this?