Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@folhomee/mongoose-tracker

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@folhomee/mongoose-tracker

Is a mongoose plugin that automatically keeps track of when the document has been created, updated and optionally when some fields have been modified

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

Mongoose Tracker

Mongoose Tracker is a mongoose plugin that automatically keeps track of when the document has been created & updated. Rewrite from old mongoose-trackable which has not been updated for 7 years

Installation

With npm

npm install @folhomee/mongoose-tracker

With Yarn :

yarn add @folhomee/mongoose-tracker

Options

FieldsTypesDefaultDescription
fieldsToTrackArray[String]noneArray that contain fields to track
nameString'__updates'name of the Array that will contains fields
limitNumber30Number of element in fieldsToTrack

Usage

Use as you would any Mongoose plugin :

const mongoose = require('mongoose')
const mongooseTracker = require('@folhomee/mongoose-tracker')

const { Schema } = mongoose.Schema

const CarsSchema = new Schema({
    tags: [String],
    description: String,
    price: { type: Number, default: 0 },
})

CarsSchema.plugin(mongooseTracker, {
    limit: 50,
    name: 'metaDescriptions',
    fieldsToTrack: ['price', 'description'],
})

module.exports = mongoose.model('Cars', CarsSchema)

When create/update is successful, a History element is pushed to __updates or the named Array

History

FieldsTypesDescription
fieldStringname of key field
changedToStringvalue of key field
atDatetime at modification

Contributing

  • Use eslint to lint your code.
  • Add tests for any new or changed functionality.
  • Update the readme with an example if you add or change any functionality.

Author: Folhomee. License Apache-2.0

Keywords

FAQs

Package last updated on 01 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc