【发布时间】:2018-01-19 03:25:00
【问题描述】:
在使用firebase云功能时,我在用户删除他的账户时遇到了以下问题,我需要从Firebase数据库中删除他的数据(我知道这可以在客户端完成,之前我这样做过) ,但现在作为开始使用云功能,我决定做这个案例。在函数日志中,我看到以下类型的错误“TypeError: admin.database.ref is not a function”,请告诉我如何解决?
我的功能
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();
});
【问题讨论】:
标签: javascript node.js firebase firebase-realtime-database google-cloud-functions