error:a hook ('orm') failed to load when lifting sails app using mongo DB
Asked Answered
H

3

6

I get this error: a hook ('orm') failed to load when trying to lift a sails app using mongoDB. This my connections.js file:

module.exports.connections = {
  mongodb: {
    adapter   : 'sails-mongo',
    host      : 'localhost',
    port      : 27017,
    database  : 'mydb1'
  }
};

And this is my models.js file:

module.exports.models = {
  connection: 'mongodb'
};

And this is my local.js file:

module.exports = {
  connections: {
    mongodb: {
      host      : 'localhost',
      port      : 27017,
      database  : 'mydb1'
    }
  }
}

Sails v 0.10.1

Any idea why this could be happening?

Thanks

Hyaloid answered 17/8, 2014 at 10:41 Comment(13)
did you install sails-mongo? (npm install sails-mongo)Volvulus
@Volvulus yes and it was successfulHyaloid
Are there no other error messages, perhaps pertaining to connecting to the database? Can you connect to the database in the console using the mongo client?Winburn
@Winburn How do I do that?Hyaloid
Do you have MongoDB installed on your system?Winburn
Assuming that MongoDB server is running on your system, you should be able to type mongo in your console to test that you can connect. If that fails, the issue is likely that you need to start the server. A quick Google for "start mongo server <your system type>" should help there.Winburn
sgress454 give you a good hint. Apart from that please delete the connection in your local.js. That isn't necessary and haven to connections with the same name could also be a problemFriedland
It's a problem with the MongoDB itself that I've been trying to fix since @Winburn suggested that I should check if mongo is working. So when I fix this issue I'll either update the post or delete it if works. Thans alot for your help.Hyaloid
i got the very same problem. i can connect to mongodb via mongo command, everything works fine in the terminal. were you able to resolve your problem?Miyasawa
for me it was a problem with mongodb itself, I wasn't even able to connect via mongo shell.Hyaloid
i see. i was too able to resolve the problem. one must not use an '@' sign in the password because it is a delimiter and messes up the connection string lol.Miyasawa
Can you post the exact error message. Usually there are more details.Neuropsychiatry
@mandeep_m91 it was a problem with mongodb itself and I fixed it. Thank youHyaloid
L
9

All you need to do is start your mongodb.

Navigate to : path_to_your_mongodb_installation_folder\MongoDB\bin\mongod.exe example : C:\Program Files\MongoDB 2.6 Standard\bin

Let us know if this helps!

Likelihood answered 13/11, 2014 at 6:46 Comment(3)
could've been commentedEnviron
this is my first response ever on stackoverflow, I'll remember next time.Likelihood
run mongod.exe then mongo.exeHyaloid
C
0

Add

models: {
    connect: 'your_mongod_db_adapter_name'
}

in both env/development and env/production fixed the problem for me

Columniation answered 6/4, 2016 at 3:3 Comment(0)
P
-1

For those if it didn't work in heroku after deploying, try to change the node js, sails, sails-mongo versions and check.

It worked for me after changing the versions to the below:

1.nodejs - 14.15.1

2.sails - ^1.5.2

3.sails-mongo - ^2.0.0

Poore answered 13/2, 2022 at 12:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.