Skip to content

Commit

Permalink
feat(edit-logs): ensures editLog's diff is flat
Browse files Browse the repository at this point in the history
  • Loading branch information
naholyr committed Sep 5, 2017
1 parent d0ee9d7 commit a67ed66
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/lib/edit-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const middleware = schema => {
}
else {
// If the model was updated, we only store a diff
const diff = deepDiff(this._original, data)
editLog.diff = diff
const changes = deepDiff(this._original, data)
editLog.diff = flattenDiff(changes)
}

this._elLogToBeSaved = new EditLog(editLog)
Expand Down Expand Up @@ -129,6 +129,8 @@ const middleware = schema => {

}

const flattenDiff = diffs => diffs.map(diff => Array.isArray(diff) && diff.length === 1 ? diff[0] : diff)


module.exports = {
EditLogSchema,
Expand Down

0 comments on commit a67ed66

Please sign in to comment.