Comparing version 0.0.1 to 0.0.2
@@ -26,2 +26,6 @@ var util = require('util'); | ||
var _whenReady = []; | ||
function whenReady(fn) { | ||
_whenReady.push(fn); | ||
} | ||
exports.connect = function (uri, done) { | ||
@@ -36,2 +40,5 @@ var options = { | ||
config.db = db; | ||
_whenReady.forEach(function (fn) { | ||
fn(db); | ||
}); | ||
done(err); | ||
@@ -41,2 +48,3 @@ }); | ||
exports.find = function () { | ||
@@ -72,2 +80,12 @@ var collection = GC(this); | ||
exports.ensureIndex = function (index) { | ||
var self = this; | ||
whenReady(function (db) { | ||
var collection = GC(self); | ||
collection.ensureIndex(index, function (err) { | ||
if (err) throw err; | ||
}); | ||
}); | ||
}; | ||
exports.init = function (target, collection) { | ||
@@ -89,3 +107,7 @@ util.inherits(target, exports); | ||
var collection = GC(this.constructor); | ||
collection.save(this, done); | ||
var self = this; | ||
collection.save(this, function (err, numAffected, details) { | ||
if (err) return done(err); | ||
done(null, self); | ||
}); | ||
}; | ||
@@ -92,0 +114,0 @@ |
{ | ||
"name": "mong", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Lightweight models for mongodb objects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9269
199