Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-plugin-created

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-plugin-created

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

  • 1.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
2
Weekly downloads
 
Created
Source

mongoose-plugin-created

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

A mongoose.js plugin to create a document creation timestamp with optional user identifier.

Installation

npm i --save mongoose-plugin-created

API Reference

Example

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

mongoose-plugin-created~options

Kind: inner property of mongoose-plugin-created

ParamTypeDefaultDescription
[options]object
[options.date]objectoptions for configuring the path for storing the date.
options.date.useVirtualbooleantrueuse 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.pathstring"created.date"the path for storing the creation date if not a virtual.
options.date.optionsobjectproperty options to set (type will always be Date). (e.g. {select: false})
[options.by]objectoptions for configuring the path for storing the creator.
options.by.pathstring"created.by"the path for storing the document creator.
options.by.refstringthe reference model to use (e.g. {by: {ref: 'ModelRefName'}})
options.by.optionsobjectproperty options to set (if not a reference the type will always be String). (e.g. {select: false})
[options.expires]objectoptions for configuring the path to store the expiration time for the document based on the date path.
options.expires.pathstring"created.expires"the path for storing the document expiration timestamp. This is an approimation due to MongoDB's method for expiring documents
options.expires.optionsobjectproperty options to set ()type will always be Date). (e.g. {select: false})

Examples

With Defaults

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)'}

With Options

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'}

License

Apache 2.0

Keywords

FAQs

Package last updated on 24 Apr 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc