fix(index): Apply various fixes to the index engine (#12501)
This commit is contained in:
@@ -237,12 +237,7 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
|
||||
): Promise<IndexTypes.QueryResultSet<TEntry>> {
|
||||
await this.#isReady_
|
||||
|
||||
const {
|
||||
keepFilteredEntities,
|
||||
fields = [],
|
||||
filters = {},
|
||||
joinFilters = {},
|
||||
} = config
|
||||
const { fields = [], filters = {}, joinFilters = {} } = config
|
||||
const { take, skip, order: inputOrderBy = {} } = config.pagination ?? {}
|
||||
|
||||
const select = normalizeFieldsSelection(fields)
|
||||
@@ -281,7 +276,6 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
|
||||
options: {
|
||||
skip,
|
||||
take,
|
||||
keepFilteredEntities,
|
||||
orderBy,
|
||||
},
|
||||
rawConfig: config,
|
||||
@@ -290,7 +284,6 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
|
||||
|
||||
const { sql, sqlCount } = qb.buildQuery({
|
||||
hasPagination,
|
||||
returnIdOnly: !!keepFilteredEntities,
|
||||
hasCount,
|
||||
})
|
||||
|
||||
@@ -310,30 +303,6 @@ export class PostgresProvider implements IndexTypes.StorageProvider {
|
||||
} as IndexTypes.QueryFunctionReturnPagination)
|
||||
: undefined
|
||||
|
||||
if (keepFilteredEntities) {
|
||||
const mainEntity = Object.keys(select)[0]
|
||||
|
||||
const ids = resultSet.map((r) => r[`${mainEntity}.id`])
|
||||
if (ids.length) {
|
||||
const result = await this.query<TEntry>(
|
||||
{
|
||||
fields,
|
||||
joinFilters,
|
||||
filters: {
|
||||
[mainEntity]: {
|
||||
id: ids,
|
||||
},
|
||||
},
|
||||
pagination: undefined,
|
||||
keepFilteredEntities: false,
|
||||
} as IndexTypes.IndexQueryConfig<TEntry>,
|
||||
sharedContext
|
||||
)
|
||||
result.metadata ??= resultMetadata
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
data: qb.buildObjectFromResultset(
|
||||
resultSet
|
||||
|
||||
Reference in New Issue
Block a user