Comparing version 0.1.4 to 0.1.5
0.1.5 / 2012-05-06 | ||
================== | ||
* Added `Collection` references to `Promise`s. | ||
* Fixed `findAndModify`. | ||
0.1.4 / 2012-05-06 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -67,3 +67,3 @@ | ||
, opts = opts || {} | ||
, promise = new Promise('index') | ||
, promise = new Promise(this, 'index') | ||
@@ -90,3 +90,3 @@ if (fn) { | ||
Collection.prototype.indexes = function (fn) { | ||
var promise = new Promise('indexes'); | ||
var promise = new Promise(this, 'indexes'); | ||
@@ -121,3 +121,3 @@ if (fn) { | ||
var promise = new Promise('update'); | ||
var promise = new Promise(this, 'update'); | ||
@@ -174,3 +174,3 @@ if (fn) { | ||
var promise = new Promise('remove'); | ||
var promise = new Promise(this, 'remove'); | ||
@@ -203,4 +203,6 @@ if (fn) { | ||
Collection.prototype.findAndModify = function (query, update, opts, fn) { | ||
var promise = new Promise(); | ||
var promise = new Promise(this, 'findAndModify'); | ||
query = query || {}; | ||
if ('object' != typeof query.query && 'object' != typeof query.update) { | ||
@@ -221,2 +223,4 @@ query = { | ||
opts = opts || {}; | ||
if (fn) { | ||
@@ -232,7 +236,3 @@ promise.on('complete', fn); | ||
debug('%s findAndModify "%j" with "%j"', this.name, query.query, query.update); | ||
this.col.findAndModify( | ||
this.cast(query) | ||
, this.options(opts) | ||
, promise.fulfill | ||
); | ||
this.col.findAndModify(query, util.options(opts), promise.fulfill); | ||
@@ -258,3 +258,3 @@ return promise; | ||
var promise = new Promise('insert'); | ||
var promise = new Promise(this, 'insert'); | ||
@@ -309,3 +309,3 @@ if (fn) { | ||
var promise = new Promise('find') | ||
var promise = new Promise(this, 'find') | ||
@@ -374,3 +374,3 @@ if (fn) { | ||
var promise = new Promise('findOne'); | ||
var promise = new Promise(this, 'findOne'); | ||
@@ -422,3 +422,3 @@ if (fn) { | ||
Collection.prototype.drop = function (fn) { | ||
var promise = new Promise('drop'); | ||
var promise = new Promise(this, 'drop'); | ||
@@ -425,0 +425,0 @@ if (fn) { |
@@ -17,2 +17,3 @@ | ||
* | ||
* @param {Collection} collection | ||
* @param {String} type | ||
@@ -22,3 +23,4 @@ * @api public | ||
function Promise (type) { | ||
function Promise (col, type) { | ||
this.col = col; | ||
this.type = type; | ||
@@ -25,0 +27,0 @@ this.completed = false; |
{ | ||
"name": "monk" | ||
, "version": "0.1.4" | ||
, "version": "0.1.5" | ||
, "main": "lib/monk.js" | ||
@@ -5,0 +5,0 @@ , "dependencies": { |
@@ -102,2 +102,3 @@ | ||
expect(p).to.be.a(Promise); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('insert'); | ||
@@ -109,2 +110,3 @@ }); | ||
expect(p).to.be.a(Promise); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('findOne'); | ||
@@ -116,2 +118,3 @@ }); | ||
expect(p).to.be.a(Promise); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('findOne'); | ||
@@ -123,2 +126,3 @@ }); | ||
expect(p).to.be.a(Promise); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('findOne'); | ||
@@ -128,5 +132,6 @@ }); | ||
it('findAndModify', function () { | ||
var p = users.findOne(); | ||
var p = users.findAndModify(); | ||
expect(p).to.be.a(Promise); | ||
expect(p.type).to.be('findOne'); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('findAndModify'); | ||
}); | ||
@@ -137,2 +142,3 @@ | ||
expect(p).to.be.a(Promise); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('findOne'); | ||
@@ -142,11 +148,13 @@ }); | ||
it('index', function () { | ||
var p = users.findOne(); | ||
var p = users.index('eee'); | ||
expect(p).to.be.a(Promise); | ||
expect(p.type).to.be('findOne'); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('index'); | ||
}); | ||
it('indexes', function () { | ||
var p = users.findOne(); | ||
var p = users.indexes(); | ||
expect(p).to.be.a(Promise); | ||
expect(p.type).to.be('findOne'); | ||
expect(p.col).to.be(users); | ||
expect(p.type).to.be('indexes'); | ||
}); | ||
@@ -153,0 +161,0 @@ |
@@ -7,3 +7,3 @@ | ||
it('Promise#type', function () { | ||
var p = new Promise('woot'); | ||
var p = new Promise(null, 'woot'); | ||
expect(p.type).to.be('woot'); | ||
@@ -10,0 +10,0 @@ }); |
25116
759