I promise i thoroughly checked through all the previous asked questions and there isn't anything similar to this. I have a firebase function that listens to onCreate on a firestore collection.
exports.sendEmail = functions.firestore.document('/Users/{documentId}')
.onCreate((snap, context) => {
const username = snap.data().username;
const email = snap.data().email;
console.log(username, email)
const mailRef = functions.firestore.document('/mail')
return mailRef.ref.set({
email: email,
subject: 'Welcome'
});
});
After a document is created in Users, i want to take the data in users and create a new document in a main collection called mail. Is this possible because i've read the docs like 10 times and there's nothing on this. Any help is highly appreciated.
/mailis not a full document path. "mail" might be a collection, but you'll need a document ID to write to as well. Or maybe accept a random document ID. What specifically are you expecting to happen? - Doug Stevenson