Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize next value #127

Open
biluochun opened this issue Jun 20, 2022 · 1 comment
Open

Customize next value #127

biluochun opened this issue Jun 20, 2022 · 1 comment

Comments

@biluochun
Copy link

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;
    },
});
@aravind-virtualTE
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants