1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00

re-jigging, making this part of filters rather than meta.

This commit is contained in:
mike12345567 2024-05-28 18:34:08 +01:00
parent f89f469e01
commit 83fa6f952a
2 changed files with 13 additions and 19 deletions

View file

@ -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

View file

@ -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