This package has been deprecated

Author message:

This package has errors - use mongoose-sequence instead

mongoose-naxmefy-autoinc-field

0.1.1 • Public • Published

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

Package Sidebar

Install

npm i mongoose-naxmefy-autoinc-field

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • naxmefy