Fixing a type issue.

This commit is contained in:
mike12345567 2024-03-26 13:52:22 +00:00
parent de518de8fa
commit 3843dc994b
1 changed files with 16 additions and 10 deletions

View File

@ -4,16 +4,19 @@ import {
QueryJson,
RelationshipFieldMetadata,
Row,
SearchFilters, SearchParams,
SearchFilters,
SearchParams,
SortDirection,
SortOrder,
SortType,
Table,
SortJson,
SortOrder,
SortDirection,
} from "@budibase/types"
import SqlQueryBuilder from "../../../../integrations/base/sql"
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 { context } from "@budibase/backend-core"
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
@ -128,17 +131,20 @@ export async function search(options: SearchParams) {
if (params.sort && !params.sortType) {
const sortField = table.schema[params.sort]
const sortType = sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING
const sortDirection = params.sortOrder === SortOrder.ASCENDING ? SortDirection.ASCENDING : SortDirection.DESCENDING
const sortObj: SortJson = {
const sortType =
sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING
const sortDirection =
params.sortOrder === SortOrder.ASCENDING
? SortDirection.ASCENDING
: SortDirection.DESCENDING
request.sort = {
[sortField.name]: {
direction: sortDirection,
type: sortType as SortType,
},
}
request.sort = sortObj
}
if (paginate) {
if (paginate && params.limit) {
request.paginate = {
limit: params.limit,
page: params.bookmark,