When one of my users creates a specific document, for example a post, I would like to add its UID to the document.
I tried to find a way to achieve that through cloud functions and the onCreate trigger, but it seems that the user's UID isn't reachable within those function.
exports.createPublication = functions.firestore
.document('publications/{publication}')
.onCreate((snap, context) => {
const newValue = snap.data();
return snapshot.ref.child('authorId').set("ID");
});
I was really suprised that Firestore doesn't add natively a AuthorId field like others databases would do (Mongo, Parse, etc...) Of course, I can add this UID from the client, but I think it is a bit dirty.