mongoose-naxmefy-autoinc-field

mongoose plugin for auto incremented fields

This package has errors - use mongoose-sequence instead
Last updated 5 years ago by naxmefy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mongoose-naxmefy-autoinc-field 
SYNC missed versions from official npm registry.

mongoose-naxmefy-autoinc-field

mongoose plugin for auto incrementing fields

npm version

Build Status Coverage Status

NPM

installation

$ npm install --save mongoose-naxmefy-autoinc-field

usage without options (ModelName as String)

var mongoose = require("mongoose");
var autoIncLib = require("mongoose-naxmefy-autoinc-field");
var autoIncPlugin = autoIncLib(mongoose);

//...

var MyModelSchema = new mongoose.Schema({
  //...
});

// This will add field "autoIncId"
MyModelSchema.plugin(autoIncPlugin('MyModel'));

//...

var MyModel = mongoose.model('MyModel', MyModelSchema);

options for autoIncLib

var mongoose = require("mongoose");
var autoIncLib = require("mongoose-naxmefy-autoinc-field");
var autoIncPlugin = autoIncLib(mongoose, {
  collection: 'MyAutoIncCollection' // Name of collection which stores the auto inc counters
});

//...

options for autoIncPlugin

var mongoose = require("mongoose");
var autoIncLib = require("mongoose-naxmefy-autoinc-field");
var autoIncPlugin = autoIncLib(mongoose);

//...

// This will add field "autoIncId"
MyModelSchema.plugin(autoIncPlugin({
  model: "MyModel", //name of this model
  field: "myModelId", // field for auto inc
  startAt: 500, // start counter (not the first!!!)
  incrementBy: 114 // increment value (first will be startAt + incrementBy - here 614)
}));

//...

contributing

found bug? create issue!

missing feature? fork, implement and start pull request...or be lazy and create an issue...

license

MIT

Current Tags

  • 0.1.1                                ...           latest (5 years ago)

2 Versions

  • 0.1.1 [deprecated]           ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (4)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |