@bedrockio/model 0.21.3 → 0.22.1
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/CHANGELOG.md +8 -0
- package/README.md +0 -2
- package/dist/cjs/search.js +0 -21
- package/dist/cjs/upsert.js +2 -0
- package/package.json +1 -1
- package/src/search.js +0 -23
- package/src/upsert.js +2 -0
- package/types/generated/upsert.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -603,8 +603,6 @@ Input to `search` will execute the optimal mongo query and supports several
|
|
|
603
603
|
advanced features:
|
|
604
604
|
|
|
605
605
|
- Array fields will be executed using `$in`.
|
|
606
|
-
- Javascript regular expressions will map to `$regex` which allows for
|
|
607
|
-
[more advanced PCRE compatible features](https://docs.mongodb.com/manual/reference/operator/query/regex/#pcre-vs-javascript).
|
|
608
606
|
- Nested objects will be automatically flattened to query subdocuments:
|
|
609
607
|
|
|
610
608
|
```
|
package/dist/cjs/search.js
CHANGED
|
@@ -351,8 +351,6 @@ function hasTextIndex(schema) {
|
|
|
351
351
|
// handling specialed query syntax:
|
|
352
352
|
// ranges:
|
|
353
353
|
// path: { min: n, max n }
|
|
354
|
-
// regex:
|
|
355
|
-
// path: "/reg/"
|
|
356
354
|
// array:
|
|
357
355
|
// path; [1,2,3]
|
|
358
356
|
function normalizeQuery(query, schema, root = {}, rootPath = []) {
|
|
@@ -364,8 +362,6 @@ function normalizeQuery(query, schema, root = {}, rootPath = []) {
|
|
|
364
362
|
}
|
|
365
363
|
} else if (isNestedQuery(key, value)) {
|
|
366
364
|
normalizeQuery(value, (0, _utils.getField)(schema, key), root, path);
|
|
367
|
-
} else if (isRegexQuery(key, value)) {
|
|
368
|
-
root[path.join('.')] = parseRegexQuery(value);
|
|
369
365
|
} else if (isArrayQuery(key, value)) {
|
|
370
366
|
root[path.join('.')] = {
|
|
371
367
|
$in: value
|
|
@@ -420,23 +416,6 @@ function isInclude(str) {
|
|
|
420
416
|
return str === 'include';
|
|
421
417
|
}
|
|
422
418
|
|
|
423
|
-
// Regex queries
|
|
424
|
-
|
|
425
|
-
const REGEX_QUERY = /^\/(.+)\/(\w*)$/;
|
|
426
|
-
function isRegexQuery(key, value) {
|
|
427
|
-
return REGEX_QUERY.test(value);
|
|
428
|
-
}
|
|
429
|
-
function parseRegexQuery(str) {
|
|
430
|
-
// Note that using the $options syntax allows for PCRE features
|
|
431
|
-
// that aren't supported in Javascript as compared to RegExp(...):
|
|
432
|
-
// https://docs.mongodb.com/manual/reference/operator/query/regex/#pcre-vs-javascript
|
|
433
|
-
const [, $regex, $options] = str.match(REGEX_QUERY);
|
|
434
|
-
return {
|
|
435
|
-
$regex,
|
|
436
|
-
$options
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
419
|
// Search field caching
|
|
441
420
|
|
|
442
421
|
function validateSearchFields(schema, definition) {
|
package/dist/cjs/upsert.js
CHANGED
package/package.json
CHANGED
package/src/search.js
CHANGED
|
@@ -398,8 +398,6 @@ function hasTextIndex(schema) {
|
|
|
398
398
|
// handling specialed query syntax:
|
|
399
399
|
// ranges:
|
|
400
400
|
// path: { min: n, max n }
|
|
401
|
-
// regex:
|
|
402
|
-
// path: "/reg/"
|
|
403
401
|
// array:
|
|
404
402
|
// path; [1,2,3]
|
|
405
403
|
function normalizeQuery(query, schema, root = {}, rootPath = []) {
|
|
@@ -411,8 +409,6 @@ function normalizeQuery(query, schema, root = {}, rootPath = []) {
|
|
|
411
409
|
}
|
|
412
410
|
} else if (isNestedQuery(key, value)) {
|
|
413
411
|
normalizeQuery(value, getField(schema, key), root, path);
|
|
414
|
-
} else if (isRegexQuery(key, value)) {
|
|
415
|
-
root[path.join('.')] = parseRegexQuery(value);
|
|
416
412
|
} else if (isArrayQuery(key, value)) {
|
|
417
413
|
root[path.join('.')] = { $in: value };
|
|
418
414
|
} else if (isEmptyArrayQuery(schema, key, value)) {
|
|
@@ -475,25 +471,6 @@ function isInclude(str) {
|
|
|
475
471
|
return str === 'include';
|
|
476
472
|
}
|
|
477
473
|
|
|
478
|
-
// Regex queries
|
|
479
|
-
|
|
480
|
-
const REGEX_QUERY = /^\/(.+)\/(\w*)$/;
|
|
481
|
-
|
|
482
|
-
function isRegexQuery(key, value) {
|
|
483
|
-
return REGEX_QUERY.test(value);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function parseRegexQuery(str) {
|
|
487
|
-
// Note that using the $options syntax allows for PCRE features
|
|
488
|
-
// that aren't supported in Javascript as compared to RegExp(...):
|
|
489
|
-
// https://docs.mongodb.com/manual/reference/operator/query/regex/#pcre-vs-javascript
|
|
490
|
-
const [, $regex, $options] = str.match(REGEX_QUERY);
|
|
491
|
-
return {
|
|
492
|
-
$regex,
|
|
493
|
-
$options,
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
474
|
// Search field caching
|
|
498
475
|
|
|
499
476
|
function validateSearchFields(schema, definition) {
|
package/src/upsert.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../src/upsert.js"],"names":[],"mappings":"AAAA,+
|
|
1
|
+
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../src/upsert.js"],"names":[],"mappings":"AAAA,+CAkCC"}
|