Reputation: 6861
When using firebase cloud functions, I encountered the following problem when a user deletes his account, I need to delete his data from the Firebase database (I know this can be done on the client side, and before that I did so), but now as a Start to use the cloud functions, I decided to do this case. In the function logs, I see the error of the following type "TypeError: admin.database.ref is not a function", please tell me how it can be fixed?
My 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();
});
Upvotes: 0
Views: 3023
Reputation: 38319
Change this:
admin.database.ref(userSearchLocationModelPath).remove();
to this:
admin.database().ref(userSearchLocationModelPath).remove();
Upvotes: 4