functions-samples icon indicating copy to clipboard operation
functions-samples copied to clipboard

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

Open puf opened this issue 6 years ago • 4 comments

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

puf avatar May 14 '18 00:05 puf

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

nicolasgarnier avatar Jun 01 '18 14:06 nicolasgarnier

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');

puf avatar Jun 01 '18 14:06 puf

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

lovince avatar Jun 19 '18 19:06 lovince

Any updates on this?

desduvauchelle avatar Apr 22 '20 05:04 desduvauchelle