vanta-api 1.2.1 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api-features.js +10 -2
package/package.json
CHANGED
package/src/api-features.js
CHANGED
|
@@ -258,6 +258,10 @@ export class ApiFeatures {
|
|
|
258
258
|
const resultObj = {};
|
|
259
259
|
const resualt = Object.entries(filters).map((el) => {
|
|
260
260
|
const [keyObj, val] = el;
|
|
261
|
+
if (val === "null") {
|
|
262
|
+
resultObj[keyObj] = null;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
261
265
|
if (
|
|
262
266
|
typeof val === "object" &&
|
|
263
267
|
(this.#isStrictObjectId(val["$eq"]) ||
|
|
@@ -281,6 +285,7 @@ export class ApiFeatures {
|
|
|
281
285
|
resultObj[keyObj] = false;
|
|
282
286
|
return;
|
|
283
287
|
}
|
|
288
|
+
|
|
284
289
|
if (typeof val === "string" && /^[0-9]+$/.test(val)) {
|
|
285
290
|
resultObj[keyObj] = parseInt(val, 10);
|
|
286
291
|
return;
|
|
@@ -313,10 +318,13 @@ export class ApiFeatures {
|
|
|
313
318
|
|
|
314
319
|
_getCollectionInfo(field) {
|
|
315
320
|
const path = this.model.schema.path(field);
|
|
316
|
-
if (!path?.options?.ref)
|
|
321
|
+
if (!path?.options?.ref && !path?.options?.type[0]?.ref)
|
|
317
322
|
throw new HandleERROR(`Invalid populate: ${field}`, 400);
|
|
318
323
|
|
|
319
|
-
const refModelName =
|
|
324
|
+
const refModelName =
|
|
325
|
+
path?.options?.ref?.toLowerCase() ||
|
|
326
|
+
path?.options?.type[0]?.ref.toLowerCase();
|
|
327
|
+
|
|
320
328
|
const collectionName = pluralize(refModelName);
|
|
321
329
|
|
|
322
330
|
return {
|