Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Patch @feathersjs/knex to fix count
Browse files Browse the repository at this point in the history
  • Loading branch information
CITIZENDOT committed Aug 15, 2024
1 parent fba167f commit 876af7b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions patches/@feathersjs+knex+5.0.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/node_modules/@feathersjs/knex/lib/adapter.js b/node_modules/@feathersjs/knex/lib/adapter.js
index e6851d4..afacfd8 100644
--- a/node_modules/@feathersjs/knex/lib/adapter.js
+++ b/node_modules/@feathersjs/knex/lib/adapter.js
@@ -125,9 +125,14 @@ class KnexAdapter extends adapter_commons_1.AdapterBase {
}
async _find(params = {}) {
const { filters, paginate } = this.filterQuery(params);
- const { name, id } = this.getOptions(params);
+ const { Model, name, id } = this.getOptions(params);
const builder = params.knex ? params.knex.clone() : this.createQuery(params);
- const countBuilder = builder.clone().clearSelect().clearOrder().count(`${name}.${id} as total`);
+ const countBuilder = Model.count(`* as total`)
+ .with(
+ 'subquery',
+ builder.clone().clearOrder()
+ )
+ .from('subquery');
// Handle $limit
if (filters.$limit) {
builder.limit(filters.$limit);

0 comments on commit 876af7b

Please sign in to comment.