xpress-mongo
Advanced tools
Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "xpress-mongo", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Light Weight ODM for mongoDb", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -197,2 +197,6 @@ const {ObjectID} = require('mongodb'); | ||
/** | ||
* Get id of current model instance | ||
* @returns {*|null} | ||
*/ | ||
XMongoModel.prototype.id = function () { | ||
@@ -202,3 +206,32 @@ return (this.data && this.data['_id']) || null | ||
/** | ||
* Compare model id with a string or ObjectId type variable. | ||
* @param to | ||
* @param key | ||
* @returns {boolean} | ||
*/ | ||
XMongoModel.prototype.idEqualTo = function (to, key = "_id") { | ||
/** | ||
* Get Value to be compared with | ||
* @type {ObjectID|string} | ||
*/ | ||
let compareWith = this.get(key, undefined); | ||
// Return false of to || compareWith is false, undefined or null | ||
if (!to || !compareWith) return false; | ||
/** | ||
* If to || compareWith is typeof objectID, we run toString() get the string value. | ||
*/ | ||
if (ObjectID.isValid(to)) to = to.toString(); | ||
if (ObjectID.isValid(compareWith)) compareWith = compareWith.toString(); | ||
// Compare Strings | ||
return to === compareWith; | ||
}; | ||
/** | ||
* See changes made so far. | ||
@@ -426,3 +459,2 @@ * @return {*} | ||
/** | ||
@@ -429,0 +461,0 @@ * Find many in collection |
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
29942
951