0
當使用firebase雲端功能時,我遇到以下問題,當用戶刪除他的帳戶時,我需要從Firebase數據庫中刪除他的數據(我知道這可以在客戶端完成,在此之前我已經這樣做),但現在開始使用雲功能,我決定做這種情況。在函數日誌中,我看到以下類型的錯誤「TypeError:admin.database.ref不是函數」,請告訴我它是如何修復的?如何從Firebase Cloud功能中刪除用戶數據(任何數據)?
我的功能
var functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
// deleting functions
exports.userDidDeleted = functions.auth.user().onDelete(event => {
const user = event.data; // The Firebase user.
const email = user.email; // The email of the user.
const displayName = user.displayName; // The display name of the user.
const userSearchLocationModelPath = '/userSearchLocationModel/' + user.uid;
admin.database.ref(userSearchLocationModelPath).remove();
});