Open eddyson1006 opened 6 years ago
I think it just happened on user saved a record with a validated failure. For example, when email is unique. User has created a new record using the same email address. . Mongodb will throw you an error and refuse to store the record, but this plugin has already counted it up.
What do you think?🤔🤔🤔 // sorry i did not seeing the date of your comment.
I have use this package in my project to provide autoincrement by 1 every time a new records come in. But somehow I can see that the increment is not consistence like id 10 to id 13 to id 14 to id 17 etc etc. Wondering what is the problem here?
I am using version as below:
"mongoose-auto-increment": "^5.0.1",
"mongoose-plugin-autoinc": "^1.1.9",
And code to use this in model as below:
var mongoose = require('mongoose'),
mongoosePaginate = require('mongoose-paginate'),
Schema = mongoose.Schema;
var user = new Schema({ ...............long list of schema here.............. })
var mongoosePages = require('mongoose-pages');
var autoIncrement = require('mongoose-plugin-autoinc');
provider.plugin(autoIncrement.plugin, {model: 'user', field: 'unique_id', startAt: 1, incrementBy: 1});