Skip to content
Source
Sign inSign up
TanStack/db

Mutable limit and offset for ordered live queries #663

Mergedkevin-dp(GitHub profile, opens in a new tab)merged 16 commits intomain fromrefs/pull/663/headmerged by samwillis(GitHub profile, opens in a new tab)

Showing 22 changed files with 136 additions and 13 deletions (loading 19).

x
0 of 22 viewed, 22 left
20 additions and 0 deletions.changeset/clever-parks-report.mdAdded
View file
@@ -0,0 +1,20 @@
+---
+"@tanstack/db-ivm": patch
+"@tanstack/db": patch
+---
+​
+Add `utils.setWindow()` method to live query collections to dynamically change limit and offset on ordered queries.
+​
+You can now change the pagination window of an ordered live query without recreating the collection:
+​
+```ts
+const users = createLiveQueryCollection((q) =>
+ q
+ .from({ user: usersCollection })
+ .orderBy(({ user }) => user.name, "asc")
+ .limit(10)
+ .offset(0)
+)
+​
+users.utils.setWindow({ offset: 10, limit: 10 })
+```
5 additions and 0 deletionspackages/db-ivm/src/operators/orderBy.tsModified
View file
@@ -13,6 +13,9 @@
​