Skip to content

Versioning models #11508

Answered by 1finedev
helloscoopa asked this question in Q&A
Mar 8, 2022 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

but if it helps you can try either of this approach

//add this line before exporting your model to empty the models each time 
mongoose.models = {}; 
const User = mongoose.model("User", userSchema)

or try this

export const User = mongoose.models.User || mongoose.model('User', userSchema);

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@helloscoopa
Comment options

Comment options

You must be logged in to vote
2 replies
@helloscoopa
Comment options

@1finedev
Comment options

Answer selected by helloscoopa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants