Skip to content

Commit

Permalink
Update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Sep 27, 2024
1 parent eacf780 commit 0537e8b
Show file tree
Hide file tree
Showing 4 changed files with 674 additions and 114 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

## Version History

### v21.2.0

- :rocket: Add support for suppressing `limit()` in List with `Infinity` value

### v21.1.0

- :rocket: Stricter TS config to keep upstream TSC happy
Expand Down
14 changes: 11 additions & 3 deletions generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,22 @@ export default class Drizzle<T extends GenericTable> {
const order = query.order && query.order === 'desc' ? desc : asc;
const orderBy = order(query.sort ? this.key(query.sort) : this.requiredPrimaryKey());

const pgres = await this.pool.select({
const limit = query.limit || 10;

const partial = this.pool.select({
count: sql<string>`count(*) OVER()`.as('count'),
generic: this.generic
}).from(this.generic)
.where(query.where)
.orderBy(orderBy)
.limit(query.limit || 10)
.offset((query.page || 0) * (query.limit || 10))

if (limit !== Infinity) {
partial
.limit(query.limit || 10)
.offset((query.page || 0) * (query.limit || 10))
}

const pgres = await partial;

if (pgres.length === 0) {
return { total: 0, items: [] };
Expand Down
Loading

0 comments on commit 0537e8b

Please sign in to comment.