Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native mongo driver throws warnings #54

Open
minicuper opened this issue Jul 18, 2017 · 5 comments
Open

native mongo driver throws warnings #54

minicuper opened this issue Jul 18, 2017 · 5 comments
Milestone

Comments

@minicuper
Copy link
Contributor

original mongo driver throws warnings if we pass sharedb specific options, like allowAllQueries
it shows: the options [allowAllQueries] is not supported

@alecgibson
Copy link
Contributor

Bumping this - I'm also finding it a bit annoying. The problem is that Mongo actively checks whether all of the options we pass it are legal, but we mingle our own options in with Mongo options.

We have probably two options:

  1. Force consumers of sharedb-mongo to put options inside a mongoOptions object, and pass that through to Mongo native (this would be a breaking change)
  2. We delete all of our own options from the options object passed into sharedb-mongo. This would be non-breaking, but would be fragile and probably quite messy.

@ericyhwang
Copy link
Contributor

There's actually already a mongoOptions constructor option for this, but it's only used when you provide a mongoPoll option:
https://github.com/share/sharedb-mongo/blob/v1.0.0-beta.8/index.js#L140-L144

I agree that it'd be good to consistently use that. Definitely something to consider lumping into 1.0 breaking changes.


Another approach, which is documented, is to pass a function that provides a Mongo client. That lets you re-use a client that you fully construct yourself, which is useful if you use Mongo in other places on the same server too.
https://github.com/share/sharedb-mongo/tree/v1.0.0-beta.8#usage

@alecgibson
Copy link
Contributor

@ericyhwang even when you use this approach, Mongo complains that mongo isn't a valid option.

@ericyhwang
Copy link
Contributor

even when you use this approach, Mongo complains that mongo isn't a valid option.

With the mongoOptions approach? Yeah, that's because sharedb-mongo only uses options.mongoOptions in the codepath where a options.mongoPoll DB URI is provided. Otherwise it uses the lower-down codepath that passes in options to the Mongo driver directly.

The second approach of a provider function gives you full control over how the Mongo client gets created and connected - here's the README example modified to add Mongo options:

const mongodb = require('mongodb');
const ShareDBMongo = require('sharedb-mongo');
const db = new ShareDBMongo({
  mongo: function(callback) {
    mongodb.connect(mongoUri, mongoOptions, callback);
  }
});
const backend = new ShareDB({db});

@alecgibson alecgibson added this to the v1.0 milestone May 18, 2021
@alecgibson
Copy link
Contributor

Looks like Nate's already done most of the work for this, and we just need to remove the fallback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants