【问题标题】:How to delete user data (any data) from Firebase Cloud functions?如何从 Firebase Cloud 功能中删除用户数据(任何数据)?
【发布时间】: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


    【解决方案1】:

    改变这个:

    admin.database.ref(userSearchLocationModelPath).remove();
    

    到这里:

    admin.database().ref(userSearchLocationModelPath).remove();
    

    【讨论】:

      猜你喜欢
      • 2019-09-18
      • 2020-07-16
      • 2018-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 2018-08-28
      • 1970-01-01
      相关资源
      最近更新 更多