-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Error Counter already defined for field "userId_counter" in Next.js typescript #100
Comments
Error: Counter already defined for field "userId_counter" |
It depends where you define the models. They should be defined just once otherwise you'll have this problem. In which file you put your definitions? How are you importing this file? If you use it in a function (let's say in /pages/api/myapi.js), try to be sure to not call the definition in the function you export, but do it outside of that function |
Hey, make sure to drop the counter collection and try again - worked for me |
@harloom try to check if your collection exist. example: if(!mongoose.models.account){
accountSchema.plugin(AutoIncrement,{id:'userId_counter',inc_field:'userId' });
} ps: to do that you need to remove and create your account collection. i hope it's solve your problem |
Hello i am build app with next.js typescript and mongoose
first time input to db is not problem. i close and run dev .i try create api i have message this error;
i try not use plugin . my code is fine
The text was updated successfully, but these errors were encountered: