@bedrockio/model 0.1.25 → 0.1.26

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.
@@ -16,7 +16,8 @@ yarn add @bedrockio/logger
16
16
  yarn add @bedrockio/model
17
17
  ```
18
18
 
19
- Replace all references to `src/utils/schema.js` and `src/utils/validation.js` to `@bedrockio/model`.
19
+ Replace all references to `src/utils/schema.js` and `src/utils/validation.js` to
20
+ `@bedrockio/model`.
20
21
 
21
22
  In the model definitions:
22
23
 
@@ -186,7 +186,7 @@ function buildKeywordQuery(schema, keyword, fields) {
186
186
  }
187
187
  function buildRegexQuery(keyword, fields) {
188
188
  return fields.map(field => {
189
- const regexKeyword = keyword.replace(/\+/g, '\\+');
189
+ const regexKeyword = (0, _lodash.escapeRegExp)(keyword);
190
190
  return {
191
191
  [field]: {
192
192
  $regex: `${regexKeyword}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/search.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import yd from '@bedrockio/yada';
2
2
  import logger from '@bedrockio/logger';
3
3
  import mongoose from 'mongoose';
4
- import { pick, isEmpty, isPlainObject } from 'lodash';
4
+ import { pick, isEmpty, escapeRegExp, isPlainObject } from 'lodash';
5
5
 
6
6
  import { isDateField, isNumberField, getField } from './utils';
7
7
  import { SEARCH_DEFAULTS } from './const';
@@ -196,7 +196,7 @@ function buildKeywordQuery(schema, keyword, fields) {
196
196
 
197
197
  function buildRegexQuery(keyword, fields) {
198
198
  return fields.map((field) => {
199
- const regexKeyword = keyword.replace(/\+/g, '\\+');
199
+ const regexKeyword = escapeRegExp(keyword);
200
200
  return {
201
201
  [field]: {
202
202
  $regex: `${regexKeyword}`,