Comparing version 0.3.0 to 0.4.0
0.4.0 / 2012-10-03 | ||
================== | ||
* added travis | ||
* manager: added Manager#id and Manager#oid | ||
* collection: introduced Collection#oid | ||
* manager: added Manager#col | ||
0.3.0 / 2012-09-06 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -46,3 +46,4 @@ | ||
Collection.prototype.id = function (str) { | ||
Collection.prototype.id = | ||
Collection.prototype.oid = function (str) { | ||
if (null == str) return this.col.ObjectID(); | ||
@@ -49,0 +50,0 @@ return 'string' == typeof str ? this.col.id(str) : str; |
@@ -9,3 +9,4 @@ | ||
, Collection = require('./collection') | ||
, EventEmitter = require('events').EventEmitter | ||
, ObjectId = mongoskin.ObjectID | ||
, EventEmitter = require('events').EventEmitter; | ||
@@ -99,2 +100,3 @@ /** | ||
Manager.prototype.col = | ||
Manager.prototype.get = function (name) { | ||
@@ -107,1 +109,15 @@ if (!this.collections[name]) { | ||
}; | ||
/** | ||
* Casts to objectid | ||
* | ||
* @param {Mixed} hex id or ObjectId | ||
* @return {ObjectId} | ||
* @api public | ||
*/ | ||
Manager.prototype.id = | ||
Manager.prototype.oid = function (str) { | ||
if (null == str) return ObjectId(); | ||
return 'string' == typeof str ? ObjectId.createFromHexString(str) : str; | ||
}; |
{ | ||
"name": "monk" | ||
, "version": "0.3.0" | ||
, "version": "0.4.0" | ||
, "main": "lib/monk.js" | ||
@@ -5,0 +5,0 @@ , "tags": ["mongodb", "mongo", "driver"] |
# monk | ||
[![build status](https://secure.travis-ci.org/LearnBoost/monk.png?branch=master)](https://secure.travis-ci.org/LearnBoost/monk) | ||
Monk is a tiny layer that provides simple yet substantial usability | ||
@@ -5,0 +7,0 @@ improvements for MongoDB usage within Node.JS. |
@@ -0,5 +1,6 @@ | ||
/*global expect*/ | ||
var monk = require('../lib/monk') | ||
, db | ||
, users, indexes | ||
, users, indexes; | ||
@@ -28,2 +29,7 @@ describe('collection', function () { | ||
}); | ||
it('#oid', function(){ | ||
var oid = users.oid(); | ||
expect(oid.toHexString()).to.be.a('string'); | ||
}); | ||
}); | ||
@@ -130,3 +136,3 @@ | ||
var query = { a: { $exists: true } } | ||
, found = 0 | ||
, found = 0; | ||
users.count(query, function (err, total) { | ||
@@ -144,3 +150,3 @@ users.find(query) | ||
done(); | ||
}) | ||
}); | ||
}); | ||
@@ -151,5 +157,5 @@ }); | ||
var query = { a: { $exists: true } } | ||
, found = 0 | ||
, found = 0; | ||
users.count(query, function (err, total) { | ||
var promise = users.find(query, { stream: true }) | ||
var promise = users.find(query, { stream: true }); | ||
process.nextTick(function () { | ||
@@ -167,3 +173,3 @@ promise | ||
done(); | ||
}) | ||
}); | ||
}); | ||
@@ -248,7 +254,7 @@ }); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
@@ -412,3 +418,3 @@ describe('findAndModifying', function () { | ||
expect(err).to.be(null); | ||
var p = col.drop(done) | ||
var p = col.drop(done); | ||
expect(p).to.be.a(Promise); | ||
@@ -415,0 +421,0 @@ expect(p.type).to.be('drop'); |
@@ -0,3 +1,4 @@ | ||
/*global expect*/ | ||
var monk = require('../lib/monk') | ||
var monk = require('../lib/monk'); | ||
@@ -45,9 +46,27 @@ describe('monk', function () { | ||
var Collection = monk.Collection; | ||
var db = monk('127.0.0.1/monk-test'); | ||
it('should retrieve a collection', function () { | ||
var db = monk('127.0.0.1/monk-test'); | ||
it('Manager#get', function () { | ||
expect(db.get('users')).to.be.a(Collection); | ||
}); | ||
it('Manager#col', function(){ | ||
expect(db.col('users')).to.be.a(Collection); | ||
}); | ||
}); | ||
describe('ObjectID casting', function(){ | ||
var db = monk('127.0.0.1/monk-test'); | ||
it('Manager#id', function(){ | ||
var oid = db.id(); | ||
expect(oid.toHexString()).to.be.a('string'); | ||
}); | ||
it('Manager#oid', function(){ | ||
var oid = db.oid(); | ||
expect(oid.toHexString()).to.be.a('string'); | ||
}); | ||
}); | ||
}); |
37674
15
1087
221