Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 : [email protected]

like image 554
nab. Avatar asked Mar 10 '17 11:03

nab.


2 Answers

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 [email protected] --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:[email protected]: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!

like image 124
Davo Avatar answered Nov 09 '22 09:11

Davo


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

You hit the nail on the head -- the current sails-mongo adapter for Sails v0.12.x uses a version of the native MongoDB driver that doesn't support all the features required to work with Atlas (e.g. authSource). See this issue on Github.

We're finishing up the last bits on the sails-mongo adapter for Sails 1.0, which supports the latest options and has been tested successfully with Atlas, so now might be a good time to start preparing to upgrade to version 1.0. After Sails 1.0 is released we'll only be doing bug fixes and security patches to modules that work with v0.12.x.

like image 27
sgress454 Avatar answered Nov 09 '22 11:11

sgress454