Fixing a type issue.
This commit is contained in:
parent
de518de8fa
commit
3843dc994b
|
@ -4,16 +4,19 @@ import {
|
||||||
QueryJson,
|
QueryJson,
|
||||||
RelationshipFieldMetadata,
|
RelationshipFieldMetadata,
|
||||||
Row,
|
Row,
|
||||||
SearchFilters, SearchParams,
|
SearchFilters,
|
||||||
|
SearchParams,
|
||||||
|
SortDirection,
|
||||||
|
SortOrder,
|
||||||
SortType,
|
SortType,
|
||||||
Table,
|
Table,
|
||||||
SortJson,
|
|
||||||
SortOrder,
|
|
||||||
SortDirection,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import SqlQueryBuilder from "../../../../integrations/base/sql"
|
import SqlQueryBuilder from "../../../../integrations/base/sql"
|
||||||
import { SqlClient } from "../../../../integrations/utils"
|
import { SqlClient } from "../../../../integrations/utils"
|
||||||
import { buildInternalRelationships, sqlOutputProcessing } from "../../../../api/controllers/row/utils"
|
import {
|
||||||
|
buildInternalRelationships,
|
||||||
|
sqlOutputProcessing,
|
||||||
|
} from "../../../../api/controllers/row/utils"
|
||||||
import sdk from "../../../index"
|
import sdk from "../../../index"
|
||||||
import { context } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
|
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
|
||||||
|
@ -128,17 +131,20 @@ export async function search(options: SearchParams) {
|
||||||
|
|
||||||
if (params.sort && !params.sortType) {
|
if (params.sort && !params.sortType) {
|
||||||
const sortField = table.schema[params.sort]
|
const sortField = table.schema[params.sort]
|
||||||
const sortType = sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING
|
const sortType =
|
||||||
const sortDirection = params.sortOrder === SortOrder.ASCENDING ? SortDirection.ASCENDING : SortDirection.DESCENDING
|
sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING
|
||||||
const sortObj: SortJson = {
|
const sortDirection =
|
||||||
|
params.sortOrder === SortOrder.ASCENDING
|
||||||
|
? SortDirection.ASCENDING
|
||||||
|
: SortDirection.DESCENDING
|
||||||
|
request.sort = {
|
||||||
[sortField.name]: {
|
[sortField.name]: {
|
||||||
direction: sortDirection,
|
direction: sortDirection,
|
||||||
type: sortType as SortType,
|
type: sortType as SortType,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
request.sort = sortObj
|
|
||||||
}
|
}
|
||||||
if (paginate) {
|
if (paginate && params.limit) {
|
||||||
request.paginate = {
|
request.paginate = {
|
||||||
limit: params.limit,
|
limit: params.limit,
|
||||||
page: params.bookmark,
|
page: params.bookmark,
|
||||||
|
|
Loading…
Reference in New Issue