Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pass options into collection constructor

  • Loading branch information...
commit b4e15f1c5df4626f0d0779adac49076c6d25e41e 1 parent d71893e
@vpulim authored
Showing with 14 additions and 5 deletions.
  1. +11 −2 lib/collection.js
  2. +3 −3 lib/db.js
View
13 lib/collection.js
@@ -1,12 +1,21 @@
var Cursor = require('./cursor').Cursor;
-var Collection = function(name) {
- this.name = name;
+var Collection = function(name, options) {
+ this._name = name;
+ this._options = options || {};
this._collection = null;
this._isConnected = false;
this._waiting = [];
}
+Collection.prototype.getName = function() {
+ return this.name;
+};
+
+Collection.prototype.getOptions = function() {
+ return this.options;
+};
+
Collection.prototype._connected = function(collection) {
var self = this;
View
6 lib/db.js
@@ -38,13 +38,13 @@ var Database = function(name, servers, options) {
}
util.inherits(Database, EventEmitter);
-Database.prototype.collection = function(name) {
+Database.prototype.collection = function(name, options) {
if (this[name]) {
return this[name];
}
var self = this,
- collection = new Collection(name);
+ collection = new Collection(name, options);
self._waiting.push(collection);
@@ -78,7 +78,7 @@ Database.prototype._connected = function() {
self._isConnected = true;
self._waiting.forEach(function(collection) {
- db.collection(collection.name, function(err, c) {
+ db.collection(collection.name, collection.options, function(err, c) {
if (err) {
self.emit('error', err);
}
Please sign in to comment.
Something went wrong with that request. Please try again.