@andrewscwei/mongodb-odm
Advanced tools
Comparing version 0.13.2 to 0.14.0
@@ -878,3 +878,3 @@ "use strict"; | ||
for (const doc of docs) { | ||
if (!is_1.default.directInstanceOf(doc._id, mongodb_1.ObjectID)) | ||
if (!types_1.typeIsValidObjectID(doc._id)) | ||
continue; | ||
@@ -884,3 +884,3 @@ yield this.cascadeDelete(doc._id); | ||
} | ||
else if (!is_1.default.nullOrUndefined(docs) && is_1.default.directInstanceOf(docs._id, mongodb_1.ObjectID)) { | ||
else if (!is_1.default.nullOrUndefined(docs) && types_1.typeIsValidObjectID(docs._id)) { | ||
yield this.cascadeDelete(docs._id); | ||
@@ -887,0 +887,0 @@ } |
@@ -29,2 +29,3 @@ "use strict"; | ||
const Aggregation_1 = __importDefault(require("../../core/Aggregation")); | ||
const types_1 = require("../../types"); | ||
const Bar_1 = __importStar(require("../models/Bar")); | ||
@@ -48,3 +49,3 @@ const Baz_1 = __importDefault(require("../models/Baz")); | ||
assert_1.default.deepStrictEqual(Object.keys(actual[0]), ['$match']); | ||
assert_1.default(is_1.default.directInstanceOf(actual[0].$match._id, mongodb_1.ObjectID)); | ||
assert_1.default(types_1.typeIsValidObjectID(actual[0].$match._id)); | ||
assert_1.default(expected[0].$match._id.equals(actual[0].$match._id)); | ||
@@ -51,0 +52,0 @@ }); |
@@ -8,2 +8,3 @@ "use strict"; | ||
const mongodb_1 = require("mongodb"); | ||
const types_1 = require("../types"); | ||
const sanitizeDocument_1 = __importDefault(require("./sanitizeDocument")); | ||
@@ -41,3 +42,3 @@ /** | ||
function sanitizeQuery(schema, query, { strict = true } = {}) { | ||
if (is_1.default.directInstanceOf(query, mongodb_1.ObjectID)) { | ||
if (types_1.typeIsValidObjectID(query)) { | ||
return { _id: query }; | ||
@@ -44,0 +45,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
const mongodb_1 = require("mongodb"); | ||
const types_1 = require("../types"); | ||
/** | ||
@@ -152,3 +153,3 @@ * Checks a value against field properties definied in a schema. | ||
case mongodb_1.ObjectID: | ||
assert_1.default(is_1.default.directInstanceOf(value, mongodb_1.ObjectID), new TypeError(`The value "${value}" is expected to be an ObjectID but instead it is a(n) ${is_1.default(value)}`)); | ||
assert_1.default(types_1.typeIsValidObjectID(value), new TypeError(`The value "${value}" is expected to be an ObjectID but instead it is a(n) ${is_1.default(value)}`)); | ||
if (is_1.default.regExp(specs.validate)) { | ||
@@ -155,0 +156,0 @@ throw new TypeError('The RegExp validation method is not supported for ObjectID values'); |
{ | ||
"name": "@andrewscwei/mongodb-odm", | ||
"version": "0.13.2", | ||
"version": "0.14.0", | ||
"description": "ODM for MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3652
241370