@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.
- package/{CHANGELOG.md → UPDATE.md} +2 -1
- package/dist/cjs/search.js +1 -1
- package/package.json +1 -1
- package/src/search.js +2 -2
|
@@ -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
|
|
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
|
|
package/dist/cjs/search.js
CHANGED
|
@@ -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 =
|
|
189
|
+
const regexKeyword = (0, _lodash.escapeRegExp)(keyword);
|
|
190
190
|
return {
|
|
191
191
|
[field]: {
|
|
192
192
|
$regex: `${regexKeyword}`,
|
package/package.json
CHANGED
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
|
|
199
|
+
const regexKeyword = escapeRegExp(keyword);
|
|
200
200
|
return {
|
|
201
201
|
[field]: {
|
|
202
202
|
$regex: `${regexKeyword}`,
|