I have a google cloud function, which currently works for firestore. I was able to convert the first variable into real-time database, but don't quite have the knowledge () to do the same for the rest of it.
How do I perform this action in realtime database?
exports.cleanupUser = functions.auth.user().onDelete(async (user) => { const dbRef = admin.database().ref('stripe_customers');//admin.firestore().collection('stripe_customers'); const customer = (await dbRef.doc(user.uid).get()).data(); await stripe.customers.del(customer.customer_id); // Delete the customers payments & payment methods in firestore. const batch = admin.firestore().batch(); const paymetsMethodsSnapshot = await dbRef .doc(user.uid) .collection('payment_methods') .get(); paymetsMethodsSnapshot.forEach((snap) => batch.delete(snap.ref)); const paymentsSnapshot = await dbRef .doc(user.uid) .collection('payments') .get(); paymentsSnapshot.forEach((snap) => batch.delete(snap.ref)); await batch.commit(); await dbRef.doc(user.uid).delete(); return; }); https://stackoverflow.com/questions/66837531/how-to-re-write-this-batch-delete-function-to-work-for-realtime-database March 28, 2021 at 08:57AM
没有评论:
发表评论