🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

mongo-created-modified

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-created-modified

Mongo collection decorator that add created and modified timestamp on documents

latest
Source
npmnpm
Version
2.0.2
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

mongo-created-modified

Decorator for a mongo collection that add created and modified timestamp to the documents.

A created-modified document will have the properties createdDate sand lastModifiedDate.

{
  createdDate: new Date(),
  lastModifiedDate: new Date(),
  data: ...
}

Usage:

var mongoCreatedModified = require('mongo-created-modified');

mongodb.Db.connect(connection, function(err, db){
  if(err) throw err;

  database.collection('createdModifiedCollection', function (err, col) {
    if(err) throw err;

    var createdModifiedCollection = mongoCreatedModified(col);

    createdModifiedCollection.insert({a: 1}, function(err, doc) {
      if(err) throw err;

      createdModifiedCollection.findAnsModify({a: 1}, [], {a: 2},function (err, doc) {
        if(err) throw err;

        // returns document with createdDate and lastModifiedDate
        console.log(doc);
      });
    })
  });
});

FAQs

Package last updated on 30 Jan 2019

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