Comparing version
@@ -0,1 +1,8 @@ | ||
0.2.2 / 2011-12-02 | ||
================== | ||
* add bind support for embeded collections, e.g. db.bind('system.js') | ||
* add method `toId` to SkinDB | ||
* add property `ObjectID`, `bson_serializer` to SkinDB. | ||
* SkinCollection.prototype.id is now deprecated. | ||
0.2.1 / 2011-11-18 | ||
@@ -2,0 +9,0 @@ ================== |
@@ -177,7 +177,7 @@ /** | ||
/** | ||
* @deprecated use SkinDb.id instead | ||
*/ | ||
SkinCollection.prototype.id = function(hex) { | ||
if(hex instanceof this.ObjectID) { | ||
return hex; | ||
} | ||
return this.skinDb.db.bson_serializer.ObjectID.createFromHexString(hex); | ||
return this.skinDb.toId(hex); | ||
}; | ||
@@ -195,3 +195,3 @@ | ||
var args = __slice.call(arguments); | ||
args[0] = {_id: this.id(args[0])}; | ||
args[0] = {_id: this.skinDb.toId(args[0])}; | ||
this.findOne.apply(this, args); | ||
@@ -205,3 +205,3 @@ }; | ||
var args = __slice.call(arguments); | ||
args[0] = {_id: this.id(args[0])}; | ||
args[0] = {_id: this.skinDb.toId(args[0])}; | ||
this.update.apply(this, args); | ||
@@ -215,3 +215,3 @@ }; | ||
var args = __slice.call(arguments); | ||
args[0] = {_id: this.id(args[0])}; | ||
args[0] = {_id: this.skinDb.toId(args[0])}; | ||
this.remove.apply(this, args); | ||
@@ -218,0 +218,0 @@ }; |
@@ -59,4 +59,14 @@ var __slice = Array.prototype.slice, | ||
this._collections = {}; | ||
this.bson_serializer = db.bson_serializer; | ||
this.ObjectID = db.bson_serializer.ObjectID; | ||
}; | ||
SkinDb.prototype.toId = function(hex) { | ||
if(hex instanceof this.ObjectID) { | ||
return hex; | ||
} | ||
return this.ObjectID.createFromHexString(hex); | ||
}; | ||
/** | ||
@@ -168,2 +178,24 @@ * retrieve native_db | ||
}); | ||
// support bind for system.js | ||
var names = name.split('.'); | ||
if(names.length > 1){ | ||
var prev = this, next; | ||
for(var i =0; i<names.length - 1; i++){ | ||
next = prev[names[i]]; | ||
if(!next){ | ||
next = {}; | ||
Object.defineProperty(prev, names[i], { | ||
value : next | ||
, writable : false | ||
, enumerable : true | ||
}); | ||
} | ||
prev = next; | ||
} | ||
Object.defineProperty(prev, names[names.length - 1], { | ||
value : args[1] | ||
, writable : false | ||
, enumerable : true | ||
}); | ||
} | ||
return args[1]; | ||
@@ -170,0 +202,0 @@ } |
{ | ||
"name": "mongoskin", | ||
"description": "The future layer above node-mongodb-native", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Jason Green <guileen@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
43052
2.54%920
3.37%