jcblw / mangos

Mango.js is a simple module to make MongoDB syntax CRUD. It uses and exposes controls straight from MongoDB's Native driver
1 stars 0 forks source link

Allow for one connection, multiple connections #4

Open jcblw opened 11 years ago

jcblw commented 11 years ago

Right now for two collections you must.

var users = new Mangos("users", ... );
var locations = new Mangos("locations", ... );
// two connections :/

I feel it would be better to

var db = new Mangos( ... );
var users = db.getCollection("users");
var locations = db.getCollection("locations");
jcblw commented 11 years ago

Seems like im a pretty big dumby so, the way it works now is that it by default uses a database and collection with the same name, doh. So this will probably break everything when this change happens. Im thinking that I can get around this by passing in an object for the initialize function.

var db = new Mangos({
  database : "app_name",
  host : "localhost",
  port : 27017,
  onReady : function(){ /* do stuff */ }
});

and use the old strings to know that the user is trying to use the older method, as you can see this will allow more functionality right off the bat.