'use strict'

var mongojs = require('mongojs');
var Promise = require('promise');
var Database = require('./lib/database');

// ObjectId
module.exports = function (connString, cols, options) {
  var connection = mongojs.apply(null, arguments);
  var db = new Database(connection);
  cols = cols || [];
  cols.forEach(function (colName) {
    db[colName] = db.collection(colName);

    var parts = colName.split('.');

    var last = parts.pop();
    var parent = parts.reduce(function (parent, prefix) {
      parent[prefix] = parent[prefix] || {};
      return parent[prefix];
    }, db);

    parent[last] = db.collection(colName);
  })
  return db;
};
@@ -647,8 +647,652 @@
 n db;%0A%7D;
+%0A%0A// expose bson stuff visible in the shell%0Amodule.exports.Binary     = mongojs.Binary      ;%0Amodule.exports.Code       = mongojs.Code        ;%0Amodule.exports.DBRef      = mongojs.DBRef       ;%0Amodule.exports.Double     = mongojs.Double      ;%0Amodule.exports.Long       = mongojs.Long        ;%0Amodule.exports.NumberLong = mongojs.NumberLong  ;%0Amodule.exports.MinKey     = mongojs.MinKey      ;%0Amodule.exports.MaxKey     = mongojs.MaxKey      ;%0Amodule.exports.ObjectID   = mongojs.ObjectID    ;%0Amodule.exports.ObjectId   = mongojs.ObjectId    ;%0Amodule.exports.Symbol     = mongojs.Symbol      ;%0Amodule.exports.Timestamp  = mongojs.Timestamp   ;%0A

Expose underlying BSON types from MongoJS (#10)