I've a very simple goal to build an auditory trigger for firestore.
I would like to save who created, when, who last updated and when for some of my documents.
I've searched up and down on all firestore documentation and it seems to be an impossible task
exports.testTrigger = functions.runWith({
timeoutSeconds: 10,
memory: '128MB'
}).firestore
.document('/environment/{prod}/companies/{company}/referrals/{ref}')
.onWrite(async (change, context) => {
return change.after.ref.set({
update_by: context.auth.uid
}, {
merge: true
});
});
context.auth is undefined even though the documentation say it should exist
I found this SO question which the first answer says is impossible
https://firebase.google.com/docs/reference/functions/firebase-functions.eventcontext.md#eventcontext_interface
the quality of googles documentation is really sick
Getting the user id from a Firestore Trigger in Cloud Functions for Firebase?
does anyone have any other ideas?