mongoose-timestamp-plugin

0.0.1 • Public • Published

mongoose-timestamp-plugin

Build Status Coverage Status

A simple, yet configurable plugin to add timestamps for creations and modifications of mongoose documents.

Installation

$ npm install mongoose-timestamp-plugin

Usage

const mongoose = require('mongoose');
const timestamp = require('mongoose-timestamp-plugin');
 
const schema = new mongoose.Schema({
    forename: String,
    surname: String,
    note: String
});
 
schema.plugin(timestamp, {
    createdName: 'created_at', // default: 'createdAt'
    updatedName: 'updated_at', // default: 'updatedAt'
    disableCreated: false, // Disables the logging of the creation date
    disableUpdated: false // Disabled the loggin of the modification date
});
 
const model = mongoose.model('Person', schema);

Package Sidebar

Install

npm i mongoose-timestamp-plugin

Weekly Downloads

82

Version

0.0.1

License

ISC

Last publish

Collaborators

  • hendrichbenjamin