Clean code
This commit is contained in:
parent
385c5f6e99
commit
ce8730f176
|
@ -76,23 +76,17 @@ export async function search(
|
||||||
const table = await sdk.tables.getTable(options.tableId)
|
const table = await sdk.tables.getTable(options.tableId)
|
||||||
options = searchInputMapping(table, options)
|
options = searchInputMapping(table, options)
|
||||||
|
|
||||||
const visibleTableFields = Object.keys(table.schema).filter(
|
if (options.query) {
|
||||||
f => table.schema[f].visible !== false
|
const tableFields = Object.keys(table.schema).filter(
|
||||||
)
|
f => table.schema[f].visible !== false
|
||||||
|
|
||||||
if (options.fields) {
|
|
||||||
const tableFields = visibleTableFields.map(f => f.toLowerCase())
|
|
||||||
options.fields = options.fields.filter(f =>
|
|
||||||
tableFields.includes(f.toLowerCase())
|
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
options.fields = visibleTableFields
|
|
||||||
}
|
|
||||||
|
|
||||||
options.query = removeInvalidFilters(
|
const queriableFields = await getQueriableFields(
|
||||||
options.query,
|
options.fields?.filter(f => tableFields.includes(f)) ?? tableFields,
|
||||||
await getQueriableFields(options.fields, table)
|
table
|
||||||
)
|
)
|
||||||
|
options.query = removeInvalidFilters(options.query, queriableFields)
|
||||||
|
}
|
||||||
|
|
||||||
let result: SearchResponse<Row>
|
let result: SearchResponse<Row>
|
||||||
if (isExternalTable) {
|
if (isExternalTable) {
|
||||||
|
|
Loading…
Reference in New Issue