I have a schema with multiple index, and using the plugin 'mongoose-plugin-autoinc' to auto increment value
Now each time I am saving I get a duplicate along with this First param to
schema.plugin()
must be a function, got "object"
const mongoose = require('mongoose');
const autoIncrement = require('mongoose-plugin-autoinc');
const connection = mongoose.createConnection("mongodb://localhost:27017/food");
const partnerSchema = new mongoose.Schema({
partnerID: { type: Number, index: true, unique: true }
});
partnerSchema.plugin(autoIncrement, {
model: 'Partner',
field: 'partnerID',
startAt: 100300,
incrementBy: 3
});
const Partner = connection.model('Partner', partnerSchema);
module.exports = Partner;