mongoose-document-log

1.0.2 • Public • Published

mongoose-document-log

A plugin for mongoose to record document change. This plugin will create a new collection called _history, it has field structure :

collectionName : string <it will record the name of your collection>, 
operation: string <this will record what the action/operation that change the document>
data: object <it contains "before" and "after" document change>

Installation

npm install --save mongoose-document-log

Usage

In your schema file, you can call this and use as plugin

const mongoose = require("mongoose");
const mongooseDocumentLog = require("mongoose-document-log");

const userSchema = new mongoose.Schema({....})

userSchema.plugin(mongooseDocumentLog)

module.export = mongoose.model("users", userSchema);

Package Sidebar

Install

npm i mongoose-document-log

Weekly Downloads

4

Version

1.0.2

License

ISC

Unpacked Size

4.55 kB

Total Files

4

Last publish

Collaborators

  • elsetiyawan