Skip to content

Commit caa070c

Browse files
committed
$contains, $regex
1 parent 3aef0a7 commit caa070c

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/bouncer/mongo-query.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ const buildQueryDoc = (node, cursor) => {
160160

161161
// single value leaf ops insert op node below given path
162162
// -> { 'param.path': { '$op': value } }
163+
case 'regex':
164+
case 'contains':
163165
case 'exists':
164166
case 'gt':
165167
case 'lt':

src/party/query.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@ module.exports = class Query {
243243
return this // enable chaining
244244
}
245245

246+
contains (value) { // @leaf `{$contains: a}`
247+
const op = { op: 'contains', param: this.cloneWhere(), value: value }
248+
this.currentMatch.push(op)
249+
return this // enable chaining
250+
}
251+
252+
regex (value) { // @leaf `{$regex: a}`
253+
const op = { op: 'regex', param: this.cloneWhere(), value: value }
254+
this.currentMatch.push(op)
255+
return this // enable chaining
256+
}
257+
246258
exists (flag) { // @leaf `{$eq: a}`
247259
const does = flag === true || flag === undefined // defaults to true
248260
const op = { op: 'exists', param: this.cloneWhere(), value: does }

0 commit comments

Comments
 (0)