-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add general string query builder
- Loading branch information
1 parent
a3a761b
commit 7cb186e
Showing
4 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const queryBuild = require('./queryBuild'); | ||
const _ = require('_'); | ||
|
||
function getStringQuery(query, paramsSearchFields, queryFieldName) { | ||
if (!_.isArray(query[queryFieldName])) { | ||
query[queryFieldName] = [query[queryFieldName]]; | ||
} | ||
for (let item of query[queryFieldName]) { | ||
let buildQs = { | ||
$or: [] | ||
}; | ||
for (let field of paramsSearchFields[queryFieldName]) { | ||
let buildResult = queryBuild.stringQuery(item, field); | ||
buildQs.$or = [...buildQs.$or, ...buildResult.$or]; | ||
} | ||
query.$and.push({ | ||
...buildQs | ||
}); | ||
} | ||
delete query[queryFieldName]; | ||
} | ||
|
||
function getFixedTokenQuery() { | ||
|
||
} | ||
|
||
function getTokenQuery(query, paramsSearchFields, queryFieldName) { | ||
|
||
} | ||
|
||
module.exports = { | ||
getStringQuery: getStringQuery | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters