Giter Club home page Giter Club logo

Comments (4)

juampi92 avatar juampi92 commented on June 18, 2024

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.

Spazer9 avatar Spazer9 commented on June 18, 2024

@juampi92 Sorry I left the last line which builds the model (that exists at the end of each model)

from adonis-mongoose-model.

Spazer9 avatar Spazer9 commented on June 18, 2024

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.

juampi92 avatar juampi92 commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.