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)
|
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
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,15 +568,8 @@ class InternalBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
read(knex: Knex, json: QueryJson, limit: number): Knex.QueryBuilder {
|
read(knex: Knex, json: QueryJson, limit: number): Knex.QueryBuilder {
|
||||||
let {
|
let { endpoint, resource, filters, paginate, relationships, tableAliases } =
|
||||||
endpoint,
|
json
|
||||||
resource,
|
|
||||||
filters,
|
|
||||||
paginate,
|
|
||||||
relationships,
|
|
||||||
tableAliases,
|
|
||||||
meta,
|
|
||||||
} = json
|
|
||||||
|
|
||||||
const tableName = endpoint.entityId
|
const tableName = endpoint.entityId
|
||||||
// select all if not specified
|
// select all if not specified
|
||||||
|
@ -606,11 +605,6 @@ class InternalBuilder {
|
||||||
aliases: tableAliases,
|
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
|
// add sorting to pre-query
|
||||||
query = this.addSorting(query, json)
|
query = this.addSorting(query, json)
|
||||||
const alias = tableAliases?.[tableName] || tableName
|
const alias = tableAliases?.[tableName] || tableName
|
||||||
|
|
|
@ -62,11 +62,15 @@ export interface SearchFilters {
|
||||||
[SearchFilterOperator.CONTAINS_ANY]?: {
|
[SearchFilterOperator.CONTAINS_ANY]?: {
|
||||||
[key: string]: 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<
|
export type SearchFilterKey = keyof Omit<
|
||||||
SearchFilters,
|
SearchFilters,
|
||||||
"allOr" | "onEmptyFilter" | "fuzzyOr"
|
"allOr" | "onEmptyFilter" | "fuzzyOr" | "documentType"
|
||||||
>
|
>
|
||||||
|
|
||||||
export type SearchQueryFields = Omit<SearchFilters, "allOr" | "onEmptyFilter">
|
export type SearchQueryFields = Omit<SearchFilters, "allOr" | "onEmptyFilter">
|
||||||
|
@ -117,10 +121,6 @@ export interface QueryJson {
|
||||||
table: Table
|
table: Table
|
||||||
tables?: Record<string, Table>
|
tables?: Record<string, Table>
|
||||||
renamed?: RenameColumn
|
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?: {
|
extra?: {
|
||||||
idFilter?: SearchFilters
|
idFilter?: SearchFilters
|
||||||
|
|
Loading…
Reference in New Issue