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

[Feature request] Consideration for altering constraints in Database::connect() #11

Open
ttacon opened this issue Feb 21, 2018 · 2 comments

Comments

@ttacon
Copy link
Contributor

ttacon commented Feb 21, 2018

Hi there - fantastic project!

I was wondering what your opinion was on relaxing the check to detect prior mongoist connections? In particular, this check will fail if the mongoist reference that is passed in is a mongoist reference where the module was loaded separately. This can happen either due to version differences, multiple linked packages during testing, or any other situation where mongoist isn't flattened to a single module under a package's node_modules. In this situation, the failure to detect the reference as a Database reference means that we'll return undefined even though we had a valid connection that we could have used to make a new connection from.

It's most likely too dangerous to reuse the connection if it was loaded via a different instance of the mongoist package as we can't be sure of API uniformity, but what do you think about using the passed in mongoist reference in order to synthesize a new mongoist reference?

@saintedlama
Copy link
Collaborator

Hi, yes the check is a bit 💩 - I'm considering to export the mongoist package name and version of and to check against that.

Considering building a new connection/mongoist instance from a passed mongoist reference does not fit the current API without a major change, perhaps expose a function createFrom to create a new connection from a given mongoist or whatever instance.

const mongoist = require('mongoist');

mongoist.createFrom(someOtherMongoistInstanceHere);

What do you think about this?

@ttacon
Copy link
Contributor Author

ttacon commented Feb 21, 2018

Awesome! I'd agree it'd be nice not to require a major version change and I like the idea of adding the necessary functionality here to a new function. 👍

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

2 participants