Request only needed fields

This commit is contained in:
Adria Navarro 2024-12-02 12:42:48 +01:00
parent 9e90103c12
commit 66857d0026
1 changed files with 6 additions and 1 deletions

View File

@ -1537,11 +1537,16 @@ class InternalBuilder {
limits?: { base: number; query: number } limits?: { base: number; query: number }
} = {} } = {}
): Knex.QueryBuilder { ): Knex.QueryBuilder {
let { operation, filters, paginate, relationships, table } = this.query const { operation, filters, paginate, relationships, table, resource } =
this.query
const { limits } = opts const { limits } = opts
// start building the query // start building the query
let query = this.qualifiedKnex() let query = this.qualifiedKnex()
if (resource?.fields) {
query = query.columns(resource?.fields)
}
// handle pagination // handle pagination
let foundOffset: number | null = null let foundOffset: number | null = null
let foundLimit = limits?.query || limits?.base let foundLimit = limits?.query || limits?.base