我嘗試使用此代碼,但不工作火力GET parrent刪除
var idUser = event.data.ref.parent.ref.parent.child('idUser').previous.val();
在此之前使用
event.data.ref.parent.ref.parent.child('idUser').onDelete(event => {
event.data.previous.val();
});
當嘗試,我得到一個錯誤這是我的全部代碼
exports.makePurchaseSummaryDelete = functions.database.ref('/invoice_data/{pushIdInvoice}/item/{pushIdItem}')
.onDelete(event => {
var name = event.data.child('itemName').previous.val();
var quantity = event.data.child('quantity').previous.val();
var idUser = event.data.ref.parent.ref.parent.child('idUser').previous.val();
var refUser = db.ref('/user_data/' + idUser + '/purchaseSummary/' + name.toUpperCase());
refUser.once("value", function(snapshotUser) {
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
return true;
});
我看不到圖片 –
@Hari:沒有Firebase雲端函數標籤。請參閱標記[更改我所做的](https://stackoverflow.com/posts/45491967/revisions),因爲我也已將它提交給您的上一個問題。請參閱我的解釋在這裏:https://stackoverflow.com/questions/42854865/what-is-the-difference-between-cloud-function-and-firebase-functions –