Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including mongoose-diff with all npm packages installed. Try it out:

var mongooseDiff = require("mongoose-diff")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mongoose-diff v0.2.0

Diffing plugin for mongoose documents

Mongoose "Diff" Plugin

Build Status

This is a simple plugin to expose changes during the pre-save hooks.

Installation

$ npm install mongoose-diff --save

Usage

var diff = require('mongoose-diff');

schema.plugin(diff, {}); // This needs to run BEFORE pre-save hooks

schema.pre('save', function(next) {
  if (this._diff) {
    // Do something with this._diff
  }
});

Change Log

0.2.0

  • Merged lchenay's pull request #1:
    • Use a virtual instead of an object property
    • Don't apply transformations during toObject() calls
  • Updated dependencies
  • Added additional testing
  • Refactored code slightly
  • Exposed a virtualName option to change the virtual name from _diff to whatever you want

0.1.0

  • Initial release
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free