Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit 4143b86

Browse files
committed
feat: Adds $search operator.
1 parent fd9d361 commit 4143b86

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"check-coverage": true
2626
},
2727
"dependencies": {
28-
"@js-entity-repos/core": "^9.0.0",
28+
"@js-entity-repos/core": "^9.1.0",
2929
"knex": "^0.14.2",
3030
"lodash": "^4.17.4"
3131
},

src/utils/filterEntities.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ const constructPropFilter = <Prop>(
5353
const lteQuery = addOpToQuery(ltQuery, prop, '<=', filterValue.$lte);
5454
const gtQuery = addOpToQuery(lteQuery, prop, '>', filterValue.$gt);
5555
const gteQuery = addOpToQuery(gtQuery, prop, '>=', filterValue.$gte);
56+
const searchQuery = (filterValue.$search === undefined ? gteQuery :
57+
gteQuery.where(prop, 'like', `%${filterValue.$search}%`)
58+
);
5659
const inQuery = (filterValue.$in === undefined ? gteQuery :
57-
gteQuery.whereIn(prop, filterValue.$in as any[])
60+
searchQuery.whereIn(prop, filterValue.$in as any[])
5861
);
5962
const ninQuery = (filterValue.$nin === undefined ? inQuery :
6063
inQuery.whereNotIn(prop, filterValue.$nin as any[])

0 commit comments

Comments
 (0)