mongoose-sequence
mongoose-sequence copied to clipboard
Customize next value
SomeSchema.plugin(AutoIncrement, {
id: '_id',
// default: counter__hooks: (next) => ++next
counter__hooks: (next: number) => {
if (next > 100) return next + 3;
if (next === 1024) return 1026;
return next + 4;
},
});
Hi biluochun if i want to auto increment based on one of the value how to achieve ? like say i have a field with value as Inactive then in that case i should not update the sequence any idea?
Thank you