Comments (4)
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.
Maybe the problem is not with this file?
Also you could use schemaOptions to define the toObject and to JSON
static get schemaOptions() {
return {
toObject: { virtuals: true },
toJSON, { virtuals: true }
}
}
from adonis-mongoose-model.
@juampi92 Sorry I left the last line which builds the model (that exists at the end of each model)
from adonis-mongoose-model.
I seem to have fixed it by changing the last line on the required models to:
module.exports = require('mongoose').models.Account || Account.buildModel('Account')
and
module.exports = require('mongoose').models.User || Account.buildModel('User')
from adonis-mongoose-model.
Mmm but that does not make sense. It seems that you have to check if mongoose has already defined.
You shouldn't.
If it throws an error is because the model is being defined somewhere else, and you need to know that.
You shouldn't build a model without doing Account.buildModel('Account').
Check for a duplicated definition of buildModel('User')
from adonis-mongoose-model.
Related Issues (20)
- Hash verify always returns false HOT 3
- Are you still planning to implement the expiration of token? HOT 2
- Populate HOT 1
- How to use plugin in model? HOT 1
- Factory.js does not work. HOT 3
- "TypeError: user.primaryKeyValue is not a function at MongooseSerializer.deleteTokens HOT 2
- MongoError: unknown top level operator: $in
- How to change collection name in model? HOT 1
- Last updates
- Is possible to use mongoose-autopopulate? HOT 1
- question: adonis model functionalities HOT 1
- Failed to connect to server HOT 2
- Access ObjectId from model HOT 2
- hook preSave not working on use updateOne HOT 2
- adonis make command in infinite execution HOT 2
- error when authenticate with JWT or API token in web socket HOT 1
- Mongo and relational database adonis js HOT 1
- Schema hasn't been registered for model
- I need to implement multi tenant
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adonis-mongoose-model.