moorea-mongoose-timestamps

0.1.1 • Public • Published

mongoose-timestamps

Dependency Status devDependency Status

simple timestamps plugin for Mongoose

Installation

npm install moorea-mongoose-timestamps

Usage

'use strict';
 
var
  mongoose   = require('mongoose'),
  timestamps = require('moorea-mongoose-timestamps');
 
var
  kittySchema = mongoose.Schema({ name: String });
 
kittySchema.plugin(timestamps);
 
module.exports = mongoose.model('Kitten', kittySchema);

A timestamps object is added to the document, with two Date properties: createdAt and modifiedAt.

 {
   timestamps: {
     createdAt : Date,
     modifiedAt: Date
   }
 }

createdAt is update every time a new document is created, modifiedAt is updated every time the document is changed.

Readme

Keywords

Package Sidebar

Install

npm i moorea-mongoose-timestamps

Weekly Downloads

3

Version

0.1.1

License

MIT

Last publish

Collaborators

  • pdesterlich