-
Notifications
You must be signed in to change notification settings - Fork 17
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
How do you ref other models? #25
Comments
Idk why it's saying about overriding the User model, cause it's not involved on that file it seems. Try to debug it by logging each step, so you'll now if something is trying to redefine the User. Also you could use schemaOptions to define the toObject and to JSON static get schemaOptions() {
return {
toObject: { virtuals: true },
toJSON, { virtuals: true }
}
} |
@juampi92 Sorry I left the last line which builds the model (that exists at the end of each model) |
I seem to have fixed it by changing the last line on the required models to:
and
|
Mmm but that does not make sense. It seems that you have to check if mongoose has already defined. If it throws an error is because the model is being defined somewhere else, and you need to know that. Check for a duplicated definition of buildModel('User') |
I'm trying to use virtuals but i'm getting an error:
"Cannot overwrite
Usermodel once compiled."
My model is like:
I looked into some solutions online like this and but i'm not sure how I can do that with this adonis integration of mongoose.
The text was updated successfully, but these errors were encountered: