Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit 12a1bce

Browse files
authored
Merge pull request #599 from FlowzPlatform/issue-594-n1
search and filter query
2 parents b13c201 + 300506a commit 12a1bce

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

client/src/pages/schema/schemaList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
isdeleted: false,
187187
'$sort[createdAt]': -1,
188188
$skip: this.skip,
189-
$limit: this.$limit,
189+
$limit: this.limit,
190190
subscriptionId: this.$store.state.subscription,
191191
userId: this.$store.state.user._id
192192
}).then(res => {

service/src/services/dflowzdata/dflowzdata.hooks.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,27 @@ let beforeFind = function (hook) {
5252
hook.params.query._currentStatus = false
5353
}
5454
}
55-
if (query.$group !== undefined) {
55+
if (query.$group !== undefined && query.$search !== undefined) {
56+
// console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
57+
hook.service.service.options.name = hook.params.headers.ftablename;
58+
hook.service.service.table = hook.service.rDB.table(hook.params.headers.ftablename);
59+
let value = hook.params.query.$group
60+
let search = hook.params.query.$search
61+
delete hook.params.query.$group
62+
delete hook.params.query.$search
63+
const query = hook.service.service.createQuery(hook.params.query);
64+
hook.params.rethinkdb = query.filter(function(doc) {
65+
return doc.coerceTo('string').match('(?i)' + search);
66+
}).group(value).ungroup()
67+
// console.log('hook.params.rethinkdb', hook.params.rethinkdb)
68+
} else if (query.$group !== undefined) {
5669
hook.service.service.options.name = hook.params.headers.ftablename;
5770
hook.service.service.table = hook.service.rDB.table(hook.params.headers.ftablename);
5871
let value = hook.params.query.$group
5972
delete hook.params.query.$group
6073
const query = hook.service.service.createQuery(hook.params.query);
6174
hook.params.rethinkdb = query.group(value).ungroup()
62-
}
63-
if (query.$search !== undefined) {
75+
} else if (query.$search !== undefined) {
6476
hook.service.service.options.name = hook.params.headers.ftablename;
6577
hook.service.service.table = hook.service.rDB.table(hook.params.headers.ftablename);
6678
let value = hook.params.query.$search
@@ -70,7 +82,6 @@ let beforeFind = function (hook) {
7082
hook.params.rethinkdb = query.filter(function(doc) {
7183
return doc.coerceTo('string').match('(?i)' + value);
7284
})
73-
// console.log('hook.params.rethinkdb', hook.params.rethinkdb)
7485
}
7586
}
7687

0 commit comments

Comments
 (0)