mongoose-timestamps
simple timestamps plugin for Mongoose
Installation
npm install moorea-mongoose-timestamps
Usage
'use strict'; var mongoose = timestamps = ; var kittySchema = mongoose; kittySchema; moduleexports = mongoose;
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.