Skip to content

Commit e6d0b9f

Browse files
authored
Merge pull request #35 from datapartyjs/browser-bundle
$regex and $contains
2 parents dc6242c + 92207c5 commit e6d0b9f

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@dataparty/api",
33
"private": false,
4-
"version": "1.2.13",
4+
"version": "1.2.14",
55
"main": "dist/dataparty.js",
66
"frontend": "dist/dataparty-browser.js",
77
"backend": "dist/dataparty.js",
@@ -36,6 +36,7 @@
3636
"context": "electron-main",
3737
"source": "src/index-embedded.js",
3838
"optimize": false,
39+
"scopeHoist": false,
3940
"includeNodeModules": true,
4041
"engines": {
4142
"node": ">= 12"

src/bouncer/mongo-query.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ 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+
node.value = new RegExp(node.value)
165+
case 'contains':
163166
case 'exists':
164167
case 'gt':
165168
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)