From 66857d00267d7eb224276147198c3f2d66bc299d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 2 Dec 2024 12:42:48 +0100 Subject: [PATCH] Request only needed fields --- packages/backend-core/src/sql/sql.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index 5f462ee144..a4828a9f4a 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -1537,11 +1537,16 @@ class InternalBuilder { limits?: { base: number; query: number } } = {} ): Knex.QueryBuilder { - let { operation, filters, paginate, relationships, table } = this.query + const { operation, filters, paginate, relationships, table, resource } = + this.query const { limits } = opts // start building the query let query = this.qualifiedKnex() + if (resource?.fields) { + query = query.columns(resource?.fields) + } + // handle pagination let foundOffset: number | null = null let foundLimit = limits?.query || limits?.base