re-jigging, making this part of filters rather than meta.
This commit is contained in:
parent
f89f469e01
commit
83fa6f952a
|
@ -397,6 +397,12 @@ class InternalBuilder {
|
|||
contains(filters.containsAny, true)
|
||||
}
|
||||
|
||||
// when searching internal tables make sure long looking for rows
|
||||
if (filters.documentType && !isExternalTable(table)) {
|
||||
// has to be its own option, must always be AND onto the search
|
||||
query.andWhereLike("_id", `${prefixed(filters.documentType)}%`)
|
||||
}
|
||||
|
||||
return query
|
||||
}
|
||||
|
||||
|
@ -562,15 +568,8 @@ class InternalBuilder {
|
|||
}
|
||||
|
||||
read(knex: Knex, json: QueryJson, limit: number): Knex.QueryBuilder {
|
||||
let {
|
||||
endpoint,
|
||||
resource,
|
||||
filters,
|
||||
paginate,
|
||||
relationships,
|
||||
tableAliases,
|
||||
meta,
|
||||
} = json
|
||||
let { endpoint, resource, filters, paginate, relationships, tableAliases } =
|
||||
json
|
||||
|
||||
const tableName = endpoint.entityId
|
||||
// select all if not specified
|
||||
|
@ -606,11 +605,6 @@ class InternalBuilder {
|
|||
aliases: tableAliases,
|
||||
})
|
||||
|
||||
// when searching internal tables make sure long looking for rows
|
||||
if (meta.documentType && !isExternalTable(meta.table)) {
|
||||
query.andWhereLike("_id", `${prefixed(meta.documentType)}%`)
|
||||
}
|
||||
|
||||
// add sorting to pre-query
|
||||
query = this.addSorting(query, json)
|
||||
const alias = tableAliases?.[tableName] || tableName
|
||||
|
|
|
@ -62,11 +62,15 @@ export interface SearchFilters {
|
|||
[SearchFilterOperator.CONTAINS_ANY]?: {
|
||||
[key: string]: any[]
|
||||
}
|
||||
// specific to SQS/SQLite search on internal tables this can be used
|
||||
// to make sure the documents returned are always filtered down to a
|
||||
// specific document type (such as just rows)
|
||||
documentType?: DocumentType
|
||||
}
|
||||
|
||||
export type SearchFilterKey = keyof Omit<
|
||||
SearchFilters,
|
||||
"allOr" | "onEmptyFilter" | "fuzzyOr"
|
||||
"allOr" | "onEmptyFilter" | "fuzzyOr" | "documentType"
|
||||
>
|
||||
|
||||
export type SearchQueryFields = Omit<SearchFilters, "allOr" | "onEmptyFilter">
|
||||
|
@ -117,10 +121,6 @@ export interface QueryJson {
|
|||
table: Table
|
||||
tables?: Record<string, Table>
|
||||
renamed?: RenameColumn
|
||||
// specific to SQS/SQLite search on internal tables this can be used
|
||||
// to make sure the documents returned are always filtered down to a
|
||||
// specific document type (such as just rows)
|
||||
documentType?: DocumentType
|
||||
}
|
||||
extra?: {
|
||||
idFilter?: SearchFilters
|
||||
|
|
Loading…
Reference in New Issue