0.0.6 • Published 28 days ago

oute-services-mongoose-audit-sdk v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
28 days ago

This module Used for mongoose collection audit

  • Initialization And Uses
  • If any transaction making multiple doc modification then you can use txn_id will be same for all
  • In this package we support bellow hooks
"save"
"update"
"updateOne"
"updateMany"
"remove"
"deleteOne"
"deleteMany"
  mongooseAuditOptions = {
    indexes: [{"created_at": -1, "document._id": 1}], //this block used for creating index on audit
    diff_only: false, //Use for storing only diff object
    excluded_keys: [], //Any key needs to be excluded from document
    connection: mongoose //Your existing mongoose object or new mongoose
    custom_collection_name: undefined //Custom collection name
    metadata: [                       //To maintain custom keys as per your requirement
      {key: "x", value: "x.y"}
      {key: "y", value: (old_obj, new_obj)=> return "x.y"}
      {key: "z", value: (old_obj, new_obj, callback)=> return callback(null, "x.y.z")}
    ]
  }
  mongooseAudit = require("oute-services-mongoose-audit-sdk")
  testSchema = mongoose.Schema({name: {type: String required: true}})
  testSchema.plugin(mongooseAudit, mongooseAuditOptions)
  Test = mongoose.model "test", testSchema, "test"

  //to get audit model, this will have all mongoose functions
  AuditModel = Test.getAuditModel()

  //to clear all audit data
  await Test.clearAuditData()
0.0.5

28 days ago

0.0.6

28 days ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago