Created
May 20, 2010 16:27
-
-
Save dvv/407762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/mongodb/bson/bson.js b/lib/mongodb/bson/bson.js | |
index 4194f5e..bf9094a 100644 | |
--- a/lib/mongodb/bson/bson.js | |
+++ b/lib/mongodb/bson/bson.js | |
@@ -214,7 +214,7 @@ BSON.deserialize = function(data, is_array_item, returnData, returnArray) { | |
// Read the oid (12 bytes) | |
var oid = data.substr(index, 12); | |
// Calculate date with miliseconds | |
- var value = new exports.ObjectID(oid); | |
+ var value = ObjectID.createPk(oid); | |
// Adjust the index | |
index = index + 12; | |
// Set the data on the object | |
@@ -500,9 +500,13 @@ ObjectID.prototype.generate = function() { | |
}; | |
ObjectID.prototype.toHexString = function() { | |
+ return ObjectID.toHexString(this.id); | |
+}; | |
+ | |
+ObjectID.toHexString = function(id) { | |
var hexString = ''; | |
- for(var index = 0; index < this.id.length; index++) { | |
- var value = BinaryParser.toByte(this.id.substr(index, 1)); | |
+ for(var index = 0; index < id.length; index++) { | |
+ var value = BinaryParser.toByte(id.substr(index, 1)); | |
var number = value <= 15 ? "0" + value.toString(16) : value.toString(16); | |
hexString = hexString + number; | |
} | |
@@ -520,7 +524,7 @@ ObjectID.prototype.__defineGetter__("generationTime", function() { | |
ObjectID.index = 0; | |
ObjectID.createPk = function() { | |
- return new exports.ObjectID(); | |
+ return new exports.ObjectID.apply(arguments); | |
}; | |
ObjectID.createFromHexString= function(hexString) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment