xpress-mongo
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -139,7 +139,20 @@ "use strict"; | ||
* Check if id is a valid id | ||
* @param objectId | ||
* @param id | ||
* @return {boolean} | ||
*/ | ||
static isValidId(objectId) { | ||
return mongodb_1.ObjectID.isValid(objectId); | ||
static isValidId(id) { | ||
const isMongoID = mongodb_1.ObjectID.isValid(id); | ||
/** | ||
* referring to this StackOverflow post | ||
* https://stackoverflow.com/questions/13850819/can-i-determine-if-a-string-is-a-mongodb-objectid | ||
* | ||
* ObjectID.isValid returns true on any 12 length string | ||
* | ||
* So converting to objectID and checking if the string value matches the original value | ||
* makes the check strict | ||
*/ | ||
if (isMongoID && typeof id === 'string') { | ||
return (new mongodb_1.ObjectID(id)).toString() === id; | ||
} | ||
return isMongoID; | ||
} | ||
@@ -146,0 +159,0 @@ /** |
{ | ||
"name": "xpress-mongo", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Light Weight ODM for mongoDb", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
@@ -184,7 +184,22 @@ import ObjectCollection = require('object-collection'); | ||
* Check if id is a valid id | ||
* @param objectId | ||
* @param id | ||
* @return {boolean} | ||
*/ | ||
static isValidId(objectId: any): boolean { | ||
return ObjectID.isValid(objectId) | ||
static isValidId(id: any): boolean { | ||
const isMongoID = ObjectID.isValid(id); | ||
/** | ||
* referring to this StackOverflow post | ||
* https://stackoverflow.com/questions/13850819/can-i-determine-if-a-string-is-a-mongodb-objectid | ||
* | ||
* ObjectID.isValid returns true on any 12 length string | ||
* | ||
* So converting to objectID and checking if the string value matches the original value | ||
* makes the check strict | ||
*/ | ||
if (isMongoID && typeof id === 'string') { | ||
return (new ObjectID(id)).toString() === id; | ||
} | ||
return isMongoID; | ||
} | ||
@@ -191,0 +206,0 @@ |
@@ -99,6 +99,6 @@ import ObjectCollection = require('object-collection'); | ||
* Check if id is a valid id | ||
* @param objectId | ||
* @param id | ||
* @return {boolean} | ||
*/ | ||
static isValidId(objectId: any): boolean; | ||
static isValidId(id: any): boolean; | ||
/** | ||
@@ -105,0 +105,0 @@ * Set Original result gotten from db |
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
122774
3294