Comparing version 0.5.4 to 0.5.5
@@ -0,1 +1,5 @@ | ||
0.5.5 2016-09-15 | ||
----------------- | ||
- Added DBPointer up conversion to DBRef | ||
0.5.4 2016-08-23 | ||
@@ -2,0 +6,0 @@ ----------------- |
@@ -391,2 +391,26 @@ "use strict" | ||
} | ||
} else if(elementType == BSON_DATA_DBPOINTER) { | ||
// Get the code string size | ||
var stringSize = buffer[index++] | buffer[index++] << 8 | buffer[index++] << 16 | buffer[index++] << 24; | ||
// Check if we have a valid string | ||
if(stringSize <= 0 || stringSize > (buffer.length - index) || buffer[index + stringSize - 1] != 0) throw new Error("bad string length in bson"); | ||
// Namespace | ||
var namespace = buffer.toString('utf8', index, index + stringSize - 1); | ||
// Update parse index position | ||
index = index + stringSize; | ||
// Read the oid | ||
var oidBuffer = new Buffer(12); | ||
buffer.copy(oidBuffer, 0, index, index + 12); | ||
var oid = new ObjectID(oidBuffer); | ||
// Update the index | ||
index = index + 12; | ||
// Split the namespace | ||
var parts = namespace.split('.'); | ||
var db = parts.shift(); | ||
var collection = parts.join('.'); | ||
// Upgrade to DBRef type | ||
object[name] = new DBRef(collection, oid, db); | ||
} else { | ||
@@ -520,2 +544,8 @@ throw new Error("Detected unknown BSON type " + elementType.toString(16) + " for fieldname \"" + name + "\", are you using the latest BSON parser"); | ||
* | ||
* @classconstant BSON_DATA_DBPOINTER | ||
**/ | ||
BSON.BSON_DATA_DBPOINTER = 12; | ||
/** | ||
* Code BSON Type | ||
* | ||
* @classconstant BSON_DATA_CODE | ||
@@ -522,0 +552,0 @@ **/ |
@@ -17,3 +17,3 @@ { | ||
], | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"author": "Christian Amor Kvalheim <christkv@gmail.com>", | ||
@@ -20,0 +20,0 @@ "contributors": [], |
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
450216
11740