From 3cd2c64674e7abe0b4ba3ed7c1890ea63c1b87b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20C=C3=A1rdenas?= Date: Thu, 28 Mar 2024 10:09:06 -0600 Subject: [PATCH] fix: other empty result responses (#1915) --- src/datastore/pg-store-v2.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/datastore/pg-store-v2.ts b/src/datastore/pg-store-v2.ts index 384fefc13..6aaa0d082 100644 --- a/src/datastore/pg-store-v2.ts +++ b/src/datastore/pg-store-v2.ts @@ -234,12 +234,11 @@ export class PgStoreV2 extends BasePgStoreModule { LIMIT ${limit} OFFSET ${offset} `; - const blocks = blocksQuery.map(r => r); return { limit, offset, - results: blocks, - total: blocks[0].total, + results: blocksQuery, + total: blocksQuery.count > 0 ? blocksQuery[0].total : 0, }; }); } @@ -534,7 +533,7 @@ export class PgStoreV2 extends BasePgStoreModule { limit, offset, results: results, - total: results[0].total, + total: results.count > 0 ? results[0].total : 0, }; }); } @@ -597,7 +596,7 @@ export class PgStoreV2 extends BasePgStoreModule { limit, offset, results: results, - total: results[0].total, + total: results.count > 0 ? results[0].total : 0, }; }); }