Firebase count num children of parent
问题 I'm trying to get the number of children for a parent node in js firebase. I'd like to have: 'user': { '-Yuna99s993m': { count: 1}, '-Yada99s993m': { count: 2}, } I'm creating a cloud function witch every time a new node is entered it should add count equal to numChildren of user node. exports.setCount = functions.database.ref('/user/{userId}').onWrite(event => { // This doesn't work const count = event.data.ref.parent.numChildren(); return event.data.ref.update({ count }); }); Any help to