5

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

Ebtessam Zoheir
  • 159
  • 1
  • 4
  • 13
  • did you install sails-mongo? (`npm install sails-mongo`) – Xinzz Aug 17 '14 at 17:16
  • @Xinzz yes and it was successful – Ebtessam Zoheir Aug 17 '14 at 20:25
  • 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? – sgress454 Aug 18 '14 at 15:49
  • @sgress454 How do I do that? – Ebtessam Zoheir Aug 18 '14 at 17:19
  • Do you [have MongoDB installed](http://www.mongodb.org/downloads) on your system? – sgress454 Aug 18 '14 at 17:33
  • 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 " should help there. – sgress454 Aug 19 '14 at 15:37
  • 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 problem – mdunisch Aug 20 '14 at 06:57
  • It's a problem with the MongoDB itself that I've been trying to fix since @sgress454 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. – Ebtessam Zoheir Aug 20 '14 at 22:12
  • 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? –  Oct 24 '14 at 20:42
  • for me it was a problem with mongodb itself, I wasn't even able to connect via mongo shell. – Ebtessam Zoheir Oct 26 '14 at 21:16
  • 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. –  Oct 27 '14 at 17:45
  • Can you post the exact error message. Usually there are more details. – Mandeep Singh Oct 31 '14 at 18:03
  • @mandeep_m91 it was a problem with mongodb itself and I fixed it. Thank you – Ebtessam Zoheir Oct 31 '14 at 18:39

3 Answers3

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!

Rahul Mishra
  • 106
  • 1
  • 2
0

Add

models: {
    connect: 'your_mongod_db_adapter_name'
}

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

Mars Zhu
  • 296
  • 2
  • 13
0

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

adi
  • 984
  • 15
  • 33