Instantly share code, notes, and snippets.

Embed
What would you like to do?
Activity Log Sample with Firestore + Cloud Functions Trigger
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firestore = admin.firestore();
exports.activityLog = functions.firestore
.document('privacy/{uid}').onWrite(snap => {
const uid = context.params.uid;
const settings = snap.data();
settings['udpate_time'] =
admin.firestore.FieldValue.serverTimestamp();
firestore.collection(
`activity_log/${uid}/entries`
).add(settings);
match /activity_log/{uid} {
allow create: if request.auth.uid == uid;
allow update: if request.auth.uid == uid && resource == null;
allow delete: if false;
}
@gauvins

This comment has been minimized.

gauvins commented Nov 7, 2018

Why is index.js missing }); at the end of the file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment