无法在 Cloud Functions for Firebase 中获取根引用

Unable to get the root ref in Cloud Functions for Firebase

还有另一种获取根引用的方法吗?

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 会给你根引用。