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

Make [collections] optional on connect #9

Closed
goldfire opened this issue Nov 30, 2011 · 5 comments
Closed

Make [collections] optional on connect #9

goldfire opened this issue Nov 30, 2011 · 5 comments

Comments

@goldfire
Copy link

I'm not familiar enough with the native mongodb driver to know if this is possible, but in drivers for other languages I'm not forced to create an array of all of the collections contained in my database.

Instead of this:

db = require('mongojs').connect('db', ['coll1', 'coll2', 'coll3', 'coll4', 'coll5', 'coll6', 'coll7', 'coll8', 'coll9']);

It would be much more convenient to be able to just do the following and have access to all of those collections:

db = require('mongojs').connect('db');

@ghost
Copy link

ghost commented Jan 23, 2012

That would be nice, but I love passing an array to select multiple collections at once. So I think the best solution would be to keep the second argument of connect, but just make it optional, and then add a .collection method like several other drivers.

@mafintosh
Copy link
Collaborator

The collections array in the constructor should already be optional an there actually already is a method on db called collection so if you want to use it in a more dynamic way you can do:

var db = require('mongojs').connect('db');

db.collection('col1').find(...);

Hope that answers your question.

@ghost
Copy link

ghost commented Jan 23, 2012

That's awesome! Do you need someone to update the documentation so people know that it's optional?

@mafintosh
Copy link
Collaborator

Yes that would be great!

@mafintosh
Copy link
Collaborator

Documentation updated with f118ee8 with an example on how to use collections dynamically

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