1 min readFeb 23, 2019
The returned object from getDiff(this, this._original) just returns the first argument passed, which is this.
I realized that the getDiff function you wrote works for regular objects, but when you use Mongoose Document Objects it returns the changed object only.
If you analyze the database document saved in the log table, the before works fine, the after is supposed to register the _.diff, but it actually just saves the whole object. Which is slightly problematic in terms of the amount of data saved.