Created
September 10, 2022 12:03
-
-
Save vnugent/b9f505ec1b430253c1187d7ca3678074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'areas': { | |
if (dbOp === 'update') { | |
const prevId = fullDocument?._change?.prevChangeId | |
if (prevId != null) { | |
const area = await getChangeLogModel().aggregate([ | |
{ $match: { _id: prevId } }, | |
{ | |
$project: | |
{ | |
changes: { | |
$filter: { | |
input: '$changes', | |
as: 'item', | |
cond: { $eq: ['$$item.fullDocument._id', fullDocument._id] } | |
} | |
} | |
} | |
}, | |
{ | |
$unwind: '$changes' | |
}]) | |
console.log('# get previous', area[0].changes.fullDocument) | |
console.log('# get current', fullDocument) | |
const diff = Diff.diffJson(area[0].changes.fullDocument.children, fullDocument.children, { ignoreWhitespace: true }) | |
console.log('#diff', diff) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment