npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mongoose-plugin-modified

v1.4.4

Published

Mongoose.js plugin to capture document modification timestamp with optional user identifier

Downloads

20

Readme

mongoose-plugin-modified

Codeship Status for CentralPing/mongoose-plugin-modified Build Status Code Climate for CentralPing/mongoose-plugin-modified Dependency Status for CentralPing/mongoose-plugin-modified

A mongoose.js plugin to capture document updates with timestamp and optional user identifier.

The modification date is updated pre-validation if a monitored field has been modified

Installation

npm i --save mongoose-plugin-modified

API Reference

Example

var modifiedPlugin = require('mongoose-plugin-modified');
var schema = Schema({...});
schema.plugin(modifiedPlugin[, OPTIONS]);

mongoose-plugin-modified~options

Kind: inner property of mongoose-plugin-modified

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | object | | | | options.optionKey | string | "modified" | the path options key to mark paths for inclusion in monitoring for modification. If no paths are tagged, document modification is monitored. | | [options.date] | object | | options for configuring the path for storing the date. | | options.date.path | string | "modified.date" | the path for storing the modified date. | | options.date.options | object | | property options to set (type will always be Date). (e.g. {select: false}) | | [options.by] | object | | options for configuring the path for storing the modifier. | | options.by.path | string | "modified.by" | the path for storing the document modifier. | | options.by.ref | string | | the reference model to use (e.g. {by: {ref: 'ModelRefName'}}) | | options.by.options | object | | property options to set (if not a reference the type will always be String). (e.g. {select: false}) |

Examples

With Monitoring Entire Document

var modifiedPlugin = require('mongoose-plugin-modified');
var schema = Schema({foo: String});
schema.plugin(modifiedPlugin);

var Foo = mongoose.model('Foo', schema);
var foo = Foo.findOne(); // foo.modified --> {}
foo.foo = 'My update'; // foo.modified --> {}
foo.save(); // foo.modified --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)'}

With Monitoring Selected Fields

var modifiedPlugin = require('mongoose-plugin-modified');
var schema = Schema({
  foo: {
    type: String,
    modified: true // indicates to monitor this field for modification
  },
  bar: {
    type: String
  }
});
schema.plugin(modifiedPlugin);

var Foo = mongoose.model('Foo', schema);
var foo = Foo.findOne(); // foo.modified --> {}
foo.foo = 'My update'; // foo.modified --> {}
foo.save(); // foo.modified --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)'}

foo.bar = 'My other update'; // foo.modified --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)'}
foo.save(); // foo.modified --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)'}
            // modified.date is not updated

License

Apache 2.0