Giter Club home page Giter Club logo

Comments (9)

juampi92 avatar juampi92 commented on June 3, 2024

Can you try using adonis@fold 4.1 and running the tests?

from adonis-mongoose-model.

jericopulvera avatar jericopulvera commented on June 3, 2024

if you have time please check the repo I made.

https://github.com/jericopulvera/adonis4.1-mongoose

from adonis-mongoose-model.

jericopulvera avatar jericopulvera commented on June 3, 2024

I have tried running the test and this is the result.

➜ yarn run test
yarn run v1.3.2
$ npm run lint

> [email protected] lint /home/user1/adonis-projects/adonis4.1-mongoose/node_modules/adonis-mongoose-model
> standard

$ nyc npm run test:local

> [email protected] test:local /home/user1/adonis-projects/adonis4.1-mongoose/node_modules/adonis-mongoose-model
> FORCE_COLOR=true node bin/index.js --local


  Hooks
    ✓ should separate correctly to mongoose (3ms)
    ✓ should throw error when invalid (1ms)
    ✓ should transform from lucid hook (0ms)

  IoC
    ✓ model should be instanciated property (0ms)

  Model
    ✓ should throw error if schema is not defined (1ms)
    ✓ should instanciate the schema (8ms)
    ✓ should define primary key (2ms)
    ✓ should define indexes (1ms)
    ✓ should define timestamps (2ms)
    ✓ should create hooks (4ms)
    ✓ should link file hooks (2ms)
  . Mongoose connections (0ms)
  . Serializers - Mongoose (0ms)

   PASSED 

  total       : 13
  passed      : 11
  skipped     : 2
  time        : 29ms
----------------------|----------|----------|----------|----------|----------------|
File                  |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------------------|----------|----------|----------|----------|----------------|
All files             |    70.07 |    54.35 |     61.9 |    73.23 |                |
 bin                  |       52 |    33.33 |     37.5 |    57.89 |                |
  index.js            |       52 |    33.33 |     37.5 |    57.89 |... 32,33,38,39 |
 providers            |    19.35 |        0 |     9.09 |    21.43 |                |
  MongooseProvider.js |    19.35 |        0 |     9.09 |    21.43 |... ,88,102,103 |
 src                  |    93.94 |       80 |     87.5 |    93.94 |                |
  utils.js            |    93.94 |       80 |     87.5 |    93.94 |          18,19 |
 src/Model            |    95.83 |    88.24 |      100 |    95.74 |                |
  Base.js             |    95.83 |    88.24 |      100 |    95.74 |         66,153 |
----------------------|----------|----------|----------|----------|----------------|
$ npm run coverage

> [email protected] coverage /home/user1/adonis-projects/adonis4.1-mongoose/node_modules/adonis-mongoose-model
> nyc report --reporter=text-lcov | coveralls


/home/user1/adonis-projects/adonis4.1-mongoose/node_modules/adonis-mongoose-model/node_modules/coveralls/bin/coveralls.js:18
        throw err;
        ^
Bad response: 422 {"message":"Couldn't find a repository matching this job.","error":true}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] coverage: `nyc report --reporter=text-lcov | coveralls`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user1/.npm/_logs/2018-04-20T07_08_25_414Z-debug.log
error Command failed with exit code 1.

from adonis-mongoose-model.

juampi92 avatar juampi92 commented on June 3, 2024

Try to enable mongo's debug. (using debug: true on the config).

Also try to create a model using new User() and logging it, and then try to save it, cause maybe the error is on the DB connection.

Encapsulate everything with try {} catch (err) { console.error(err) } so you know more about the error

You should use adonis's controllers, although I think you do but this inline handler is for this example.

Let me know what you find.

from adonis-mongoose-model.

jericopulvera avatar jericopulvera commented on June 3, 2024

@juampi92 I did what you told me.

Route.get('/', async () => {

  try {
    const foo = new Foo({ name: 'TEST' })
    foo.save()
    console.log(foo)
  } catch (err) { console.error(err) }


  return foo
})

It's not loading forever now but it's not saving to the database.
And also i can see the log.
{ _id: uniqueString, name: 'TEST' }

from adonis-mongoose-model.

juampi92 avatar juampi92 commented on June 3, 2024

And do you see anything regarding the mongoose debug? An insert? I think the error might be that mongoose is not connecting to the database.
Maybe the user/pw don't match, or something is off and fails silently

from adonis-mongoose-model.

jericopulvera avatar jericopulvera commented on June 3, 2024

@juampi92 where do I see the debug log?

I tried manually changing the connection but it still won't work

 Mongoose.Promise = global.Promise
 Mongoose.connect('mongodb://localhost:27017/adonis_mongoose')

I have tried simple mongoose in provider and it works with that string. But It's not working at your package.

from adonis-mongoose-model.

jericopulvera avatar jericopulvera commented on June 3, 2024

@juampi92 have you tried this at adonis 4.1?

from adonis-mongoose-model.

juampi92 avatar juampi92 commented on June 3, 2024

@jericopulvera it seems that adonis 4.1 defers the singleton calls, and combined with a but of mine, the connection to mongoose is never triggered by the serviceProvider.

I'm going to fix this, but in the meantime you can use('Mongoose') (notice Mongoose with M not m) or use('Adonis/Addons/Mongoose')

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.