I have made a function in javascript via node js which takes care that when a document is deleted, it deletes the folder associated to it. But there's something wrong can anyone help me out. In my storage i have a main folder with name 'Memories' and then sub-directories with userId as the name and then inside them are the pictures posted by the user. So i want to delete the sub-directory associated with the user.
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
admin.initializeApp();
exports.onDeleteAccount = functions.region('asia-south1').firestore
.document("/users/{userId}")
.onDelete(async (snapshot, context) => {
const userId = context.params.userId;
storage.bucket('firebasePrjectId.appspot.com').file('Moments').file(userId).delete();
});