Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
mongoose-plugin-created
Advanced tools
Mongoose.js plugin to capture document creation timestamp with optional user identifier
A mongoose.js plugin to create a document creation timestamp with optional user identifier.
npm i --save mongoose-plugin-created
Example
var createdPlugin = require('mongoose-plugin-created');
var schema = Schema({...});
schema.plugin(createdPlugin[, OPTIONS]);
Kind: inner property of mongoose-plugin-created
Param | Type | Default | Description |
---|---|---|---|
[options] | object | ||
[options.date] | object | options for configuring the path for storing the date. | |
options.date.useVirtual | boolean | true | use a virtual path to infer the document creation date from the ObjectId _id . Will revert to a real path if options.date.options are specified. |
options.date.path | string | "created.date" | the path for storing the creation date if not a virtual. |
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 creator. | |
options.by.path | string | "created.by" | the path for storing the document creator. |
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}) | |
[options.expires] | object | options for configuring the path to store the expiration time for the document based on the date path. | |
options.expires.path | string | "created.expires" | the path for storing the document expiration timestamp. This is an approimation due to MongoDB's method for expiring documents |
options.expires.options | object | property options to set ()type will always be Date ). (e.g. {select: false}) |
var createdPlugin = require('mongoose-plugin-created');
var schema = Schema({foo: String});
schema.plugin(createdPlugin);
var Foo = mongoose.model('Foo', schema);
var foo = Foo(); // foo.created --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)'}
var createdPlugin = require('mongoose-plugin-created');
var schema = Schema({foo: String});
schema.plugin(createdPlugin, {by: {ref: 'UserModel'}});
var Foo = mongoose.model('Foo', schema);
var foo = Foo(); // foo.created --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)'}
foo.created.by = userA; // foo.created --> {date: 'Wed May 05 2015 12:05:50 GMT-0400 (EDT)', by: '507f191e810c19729de860ea'}
Apache 2.0
FAQs
Mongoose.js plugin to capture document creation timestamp with optional user identifier
The npm package mongoose-plugin-created receives a total of 3 weekly downloads. As such, mongoose-plugin-created popularity was classified as not popular.
We found that mongoose-plugin-created 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
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.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.