mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-12 08:19:07 +00:00
Accept orderby: as alternative for sort:
This commit is contained in:
parent
0fad346df6
commit
93c6031bb1
@ -849,7 +849,8 @@ self.list = async (req, res) => {
|
|||||||
filterObj.queries = searchQuery.parse(filters, {
|
filterObj.queries = searchQuery.parse(filters, {
|
||||||
keywords: keywords.concat([
|
keywords: keywords.concat([
|
||||||
'is',
|
'is',
|
||||||
'sort'
|
'sort',
|
||||||
|
'orderby'
|
||||||
]),
|
]),
|
||||||
ranges,
|
ranges,
|
||||||
tokenize: true,
|
tokenize: true,
|
||||||
@ -857,6 +858,13 @@ self.list = async (req, res) => {
|
|||||||
offsets: false
|
offsets: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Accept orderby as alternative for sort
|
||||||
|
if (filterObj.queries.orderby) {
|
||||||
|
if (!filterObj.queries.sort) filterObj.queries.sort = []
|
||||||
|
filterObj.queries.sort = filterObj.queries.sort.concat(filterObj.queries.orderby)
|
||||||
|
delete filterObj.queries.orderby
|
||||||
|
}
|
||||||
|
|
||||||
// For some reason, single value won't be in Array even with 'alwaysArray' option
|
// For some reason, single value won't be in Array even with 'alwaysArray' option
|
||||||
if (typeof filterObj.queries.exclude.text === 'string')
|
if (typeof filterObj.queries.exclude.text === 'string')
|
||||||
filterObj.queries.exclude.text = [filterObj.queries.exclude.text]
|
filterObj.queries.exclude.text = [filterObj.queries.exclude.text]
|
||||||
|
Loading…
Reference in New Issue
Block a user