Comparing version 0.0.6 to 0.0.7
@@ -37,2 +37,7 @@ 'use strict'; | ||
// fast exit | ||
if (dbdata === undefined || dbdata === null) { | ||
return undefined; | ||
} | ||
if (typeof(dbdata) === 'object') { | ||
@@ -769,17 +774,26 @@ for (key in dbdata) { | ||
if (value !== undefined && value !== null) { | ||
if (value instanceof ObjectID) { | ||
return value; | ||
} | ||
// if string try to convert | ||
if (typeof value === 'string' && value.length === 24 && objectIdRegExp.test(value)) { | ||
return ObjectID.createFromHexString(value); | ||
} | ||
// value exists, now it can be either an _id or and object with an _id | ||
if (value._id !== undefined) { | ||
if (value._id !== null) { | ||
if (!(value._id instanceof ObjectID)) { | ||
// TODO: this is wrong we should use the callbacks | ||
throw new Error(key + ' must be a ObjectId Object'); | ||
if (value.hasOwnProperty('_id')) { | ||
if (value._id !== undefined) { | ||
if (value._id === null) { | ||
return null; | ||
} | ||
if (value._id instanceof ObjectID) { | ||
return value._id; | ||
} | ||
} | ||
return value._id; | ||
} | ||
if (!(value instanceof ObjectID)) { | ||
// TODO: this is wrong we should use the callbacks | ||
throw new Error(key + ' must be a ObjectId Object'); | ||
} | ||
// TODO: this is wrong we should use the callbacks | ||
throw new Error(key + ' must be a ObjectId Object'); | ||
} | ||
@@ -786,0 +800,0 @@ return value; |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"engines": { | ||
@@ -11,0 +11,0 @@ "node": ">=0.4.12" |
Sorry, the diff of this file is not supported yet
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
80268
1676