New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-vermongo

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-vermongo

Versioning module for MongoDB

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Vermongo Mongoose Plugin

npm versionBuild Status

Keeps history for mongoose documents.

Spec for Vermongo [link]

Installation

npm install mongoose-vermongo

Usage

var mongoose = require('mongoose');
var vermongo = require('mongoose-vermongo');
mongoose.Promise = require('bluebird');

var Schema = mongoose.Schema;

var pageSchema = new Schema({
  title : { type : String, required : true},
  content : { type : String, required : true },
  path : { type : String, required : true},
  tags : [String],

  lastModified : Date,
  created : Date
});
pageSchema.plugin(vermongo, "pageschemas.vermongo");

mongoose.connect("mongodb://localhost:27017/mongotest");
mongoose.connection.on('error', () => {
  console.log(`MongoDB connection error. Please make sure MongoDB is running.`);
  process.exit();
});

mongoose.connection.on('connected', () => {
  const Page = mongoose.model('PageSchema', pageSchema);
  var page = new Page({ title: "test", content: "foobar", path: "lala", tags: ["a", "b"] });
  page.save()
    .then((page) => { page.title = "test 2"; return page.save(); })
    .then((page) => { return page.remove(); })
    .then((page) => { process.exit(); })
    .catch((err) => { console.log(err); process.exit(); })
});

Which will result in two Collections,

pageschemas

There will be 0 records

pageschemas.vermongo

There will be 3 records:

{
    "_id" : {
        "_version" : 1,
        "_id" : ObjectId("589dd2b21dd3a1d7ef101e98")
    },
    "title" : "test",
    "content" : "foobar",
    "path" : "lala",
    "_version" : 1,
    "tags" : [ 
        "a", 
        "b"
    ]
}

/* 2 */
{
    "_id" : {
        "_version" : 2,
        "_id" : ObjectId("589dd2b21dd3a1d7ef101e98")
    },
    "title" : "test 2",
    "content" : "foobar",
    "path" : "lala",
    "_version" : 2,
    "tags" : [ 
        "a", 
        "b"
    ]
}

/* 3 */
{
    "_id" : {
        "_version" : 3,
        "_id" : ObjectId("589dd2b21dd3a1d7ef101e98")
    },
    "_version" : -1,
    "tags" : []
}

LICENSE

MIT License

Keywords

FAQs

Package last updated on 19 Feb 2017

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