Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
mongoose-plugin-modified
Advanced tools
Mongoose.js plugin to capture document modification timestamp with optional user identifier
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
npm i --save mongoose-plugin-modified
Example
var modifiedPlugin = require('mongoose-plugin-modified');
var schema = Schema({...});
schema.plugin(modifiedPlugin[, 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}) |
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)'}
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
Apache 2.0
FAQs
Mongoose.js plugin to capture document modification timestamp with optional user identifier
We found that mongoose-plugin-modified demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.