Search code examples
mongodbsails.jsmongodb-atlassails-mongo

mongoDB Atlas ♥︎ Sailsjs (waterline sails-mongo adapter)


i just created a MongoDB Atlas account.

I'm using sails with waterline sails-mongo adapter

but I can't manage to connect via my app.

  • Everything is up to date.
  • I can connect to any other DB (localhost, digitalocean server, ...)
  • I can also connect to that MongoDB Atlas Database via their tool (MongoDB Compass) and via shell with the mongo cmd

but it seems like sails-mongo is just not working with that db, which requires a very up-to-date mongo version

Is someone else using MDB Atlas && sailsjs ? (I thought about refactoring my app, but it's starting to be huuge and it just seems impossible to use the "mongodb" adapter)

Versions : - node : 6.3.1 - npm : 3.10.6 - mongo (shell) : 3.4.2 - sails-mongo npm module : sails-mongo@0.12.2


Solution

  • Hey people thanks to your tips and SailsJS team I was able to figure out a few things that can help you fix this issue (I was able to):

    • Update your sails-mongo to v0.12.3 npm install sails-mongo@0.12.3 --save
    • Update sails-mongo's mongodb dependency to v2.2.25. You can do this editing package.json. That version includes a fix for replicaSets connections: https://github.com/mongodb/node-mongodb-native/commit/915d5c8a765151fb14942445a92d92a0e9e9c942#diff-88dc7475eedf918122374be6d7c2c151R12
    • Make sure that the mongodb's mongodb-core version is at least v2.1.9.
    • Now I went directly and created my connection like this:

      { adapter: 'sails-mongo', url: 'mongodb://user:pass@server-1.mongodb.net:27017,server-2.mongodb.net:27017,server-3.mongodb.net:27017/test?ssl=true&replicaSet=server-&authSource=admin', ssl: true }

      Yes, you need to add the ssl parameter again.

    By looking at the sails v1.0 code, lost of this things will be fixed by that update ;) Thanks SailsJS Team!