Skip to content

Instantly share code, notes, and snippets.

View vlilloh's full-sized avatar
📑
Reading

Vicente Lillo vlilloh

📑
Reading
View GitHub Profile
@vlilloh
vlilloh / index.js
Created November 5, 2018 06:47
[Firebase] Move a collection in Cloud Firestore with a Cloud Function
exports.mv = functions.https.onRequest(request => {
const mv = async (collRefSource, collRefDest) => {
const querySnapshot = await collRefSource.get();
querySnapshot.forEach(async docSnapshot => {
(async () => {
await collRefDest.doc(docSnapshot.id).set(docSnapshot.data());
docSnapshot.ref.delete();
})();
const collRefs = await docSnapshot.ref.getCollections();
for (const collRef of collRefs)