wip
This commit is contained in:
parent
95f5844a44
commit
7e4f571eb3
|
@ -94,7 +94,18 @@ describe.each([
|
||||||
|
|
||||||
private async performSearch(): Promise<Row[]> {
|
private async performSearch(): Promise<Row[]> {
|
||||||
if (isInMemory) {
|
if (isInMemory) {
|
||||||
return dataFilters.runQuery(rows, this.query.query)
|
let result = dataFilters.runQuery(rows, this.query.query)
|
||||||
|
if (this.query.sort) {
|
||||||
|
result = dataFilters.sort(
|
||||||
|
result,
|
||||||
|
this.query.sort,
|
||||||
|
this.query.sortOrder || SortOrder.ASCENDING
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (this.query.limit) {
|
||||||
|
result = dataFilters.limit(result, this.query.limit.toString())
|
||||||
|
}
|
||||||
|
return result
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
await config.api.row.search(table._id!, {
|
await config.api.row.search(table._id!, {
|
||||||
|
|
|
@ -7,9 +7,9 @@ import {
|
||||||
SearchFilters,
|
SearchFilters,
|
||||||
SearchQueryFields,
|
SearchQueryFields,
|
||||||
SearchFilterOperator,
|
SearchFilterOperator,
|
||||||
SortDirection,
|
|
||||||
SortType,
|
SortType,
|
||||||
FieldConstraints,
|
FieldConstraints,
|
||||||
|
SortOrder,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants"
|
import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants"
|
||||||
|
@ -454,7 +454,7 @@ export const runQuery = (docs: any[], query?: SearchFilters) => {
|
||||||
export const sort = (
|
export const sort = (
|
||||||
docs: any[],
|
docs: any[],
|
||||||
sort: string,
|
sort: string,
|
||||||
sortOrder: SortDirection,
|
sortOrder: SortOrder,
|
||||||
sortType = SortType.STRING
|
sortType = SortType.STRING
|
||||||
) => {
|
) => {
|
||||||
if (!sort || !sortOrder || !sortType) {
|
if (!sort || !sortOrder || !sortType) {
|
||||||
|
|
Loading…
Reference in New Issue