There is another way for get the root ref?
exports.orderUser = functions.database.ref('/orders/{shopId}/{orderId}').onWrite(event => {
var eventSnapshot = event.data;
// ...
var rootRef = eventSnapshot.ref.parent.parent.parent; <== this line
var userRef = rootRef.child(`/users/${user}/orders`);
});
eventSnapshot.ref.root
will give you the root reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With