Skip to content

SimonSun1988/mongoose-easy-auto-increment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongoose-easy-auto-increment

mongoose field auto increment more easier

Install

npm install mongoose-easy-auto-increment --save

Usage

import mongoose from 'mongoose';
import autoIncrement from 'mongoose-easy-auto-increment';

let connection = mongoose.createConnection('your-mongodb-url');

let userSchema = new mongoose.Schema({
    name: String,
    age: Number
});

userSchema.plugin(autoIncrement, { field: 'sn', collection: 'Counters' });

let User = connection.model('User', userSchema);

module.exports = {
    User
};

Schema Plugin Options

name description
field The name of the field to increment. default is sn
collection Default collection name is SerialNumberCounters. You can change it.

About

mongoose field auto increment more easier

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors