1
0
Fork 0
mirror of synced 2024-07-13 02:05:54 +12:00
This commit is contained in:
Sam Rose 2024-06-12 15:23:35 +01:00
parent 95f5844a44
commit 7e4f571eb3
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View file

@ -94,7 +94,18 @@ describe.each([
private async performSearch(): Promise<Row[]> {
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 {
return (
await config.api.row.search(table._id!, {

View file

@ -7,9 +7,9 @@ import {
SearchFilters,
SearchQueryFields,
SearchFilterOperator,
SortDirection,
SortType,
FieldConstraints,
SortOrder,
} from "@budibase/types"
import dayjs from "dayjs"
import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants"
@ -454,7 +454,7 @@ export const runQuery = (docs: any[], query?: SearchFilters) => {
export const sort = (
docs: any[],
sort: string,
sortOrder: SortDirection,
sortOrder: SortOrder,
sortType = SortType.STRING
) => {
if (!sort || !sortOrder || !sortType) {