Skip to content
Source
Sign inSign up
TanStack/db

Modify topK and orderBy to track by key instead of by object reference #405

Mergedkevin-dp(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/405/headmerged by kevin-dp(GitHub profile, opens in a new tab)

Showing 8 changed files with 17 additions and 29 deletions (loading 6).

x
0 of 8 viewed, 8 left
6 additions and 0 deletions.changeset/polite-islands-kiss.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+"@tanstack/db-ivm": patch
+"@tanstack/db": patch
+---
+​
+Fix bug with orderBy that resulted in query results having less rows than the configured limit.
11 additions and 29 deletionspackages/db-ivm/src/operators/orderBy.tsModified
View file
@@ -138,6 +138,9 @@
) => Ve,
options?: OrderByOptions<Ve>
) {
+ type KeyType = T extends KeyValue<infer K, unknown> ? K : never
+ type ValueType = T extends KeyValue<unknown, infer V> ? V : never
+​
const limit = options?.limit ?? Infinity
const offset = options?.offset ?? 0
const comparator =
@@ -151,37 +154,16 @@
​
return (
stream: IStreamBuilder<T>