Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diff between before/after data in Cloud Functions?

Is there a method in Cloud Functions to identify all changes in a document triggered by an update in Firestore?

Perhaps something along the lines of:

exports.onUserUpdate = functions.firestore
  .document('users/{userID}')
  .onWrite((change, context) => {
    const beforeData = change.before.data();
    const afterData = change.after.data();
    const changedKeys = diffDocuments(beforeData, afterData);
})
like image 760
warfield Avatar asked Oct 26 '25 10:10

warfield


1 Answers

There's nothing provided by the SDK, if that's what you're asking. You'd have to implement diffDocuments on your own.

If you're asking if someone else has implemented something, "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow" according to the site guidelines. So that sort of question would need to be asked elsewhere.

like image 54
Doug Stevenson Avatar answered Oct 29 '25 08:10

Doug Stevenson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!