metal-orm 1.0.77 → 1.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6595,11 +6595,9 @@ async function executePagedQuery(builder, session, options, countCallback) {
6595
6595
  throw new Error("executePaged: pageSize must be an integer >= 1");
6596
6596
  }
6597
6597
  const offset = (page - 1) * pageSize;
6598
- const [items, totalItems] = await Promise.all([
6599
- builder.limit(pageSize).offset(offset).execute(session),
6600
- countCallback(session)
6601
- ]);
6602
- return { items, totalItems };
6598
+ const totalItems = await countCallback(session);
6599
+ const items = await builder.limit(pageSize).offset(offset).execute(session);
6600
+ return { items, totalItems, page, pageSize };
6603
6601
  }
6604
6602
  function buildWhereHasPredicate(env, context, relationFacet, createChildBuilder, relationName, callbackOrOptions, maybeOptions, negate = false) {
6605
6603
  const relation = env.table.relations[relationName];
@@ -7482,11 +7480,11 @@ var SelectQueryBuilder = class _SelectQueryBuilder {
7482
7480
  * Executes the query and returns both the paged items and the total.
7483
7481
  *
7484
7482
  * @example
7485
- * const { items, totalItems } = await qb.executePaged(session, { page: 1, pageSize: 20 });
7483
+ * const { items, totalItems, page, pageSize } = await qb.executePaged(session, { page: 1, pageSize: 20 });
7486
7484
  */
7487
7485
  async executePaged(session, options) {
7488
7486
  const builder = this.ensureDefaultSelection();
7489
- return executePagedQuery(builder, session, options, (sess) => this.count(sess));
7487
+ return executePagedQuery(builder, session, options, (sess) => builder.count(sess));
7490
7488
  }
7491
7489
  /**
7492
7490
  * Executes the query with provided execution and hydration contexts