@@ -3,7 +3,10 @@ import {
33 toExpression ,
44} from "../query/builder/ref-proxy"
55import { compileSingleRowExpression } from "../query/compiler/evaluators.js"
6- import { optimizeExpressionWithIndexes , findIndexForField } from "../utils/index-optimization.js"
6+ import {
7+ findIndexForField ,
8+ optimizeExpressionWithIndexes ,
9+ } from "../utils/index-optimization.js"
710import { ensureIndexForField } from "../indexes/auto-index.js"
811import { makeComparator } from "../utils/comparison.js"
912import type {
@@ -13,7 +16,7 @@ import type {
1316} from "../types"
1417import type { Collection , CollectionImpl } from "./index.js"
1518import type { SingleRowRefProxy } from "../query/builder/ref-proxy"
16- import type { BasicExpression , OrderBy , PropRef } from "../query/ir.js"
19+ import type { BasicExpression , OrderBy } from "../query/ir.js"
1720
1821/**
1922 * Interface for a collection-like object that provides the necessary methods
@@ -40,15 +43,15 @@ function getOrderedKeys<T extends object, TKey extends string | number>(
4043 orderBy : OrderBy ,
4144 limit ?: number ,
4245 whereFilter ?: ( item : T ) => boolean ,
43- optimizedOnly ?: boolean ,
46+ optimizedOnly ?: boolean
4447) : Array < TKey > | undefined {
4548 // For single-column orderBy on a ref expression, try index optimization
4649 if ( orderBy . length === 1 ) {
4750 const clause = orderBy [ 0 ] !
4851 const orderByExpression = clause . expression
4952
5053 if ( orderByExpression . type === `ref` ) {
51- const propRef = orderByExpression as PropRef
54+ const propRef = orderByExpression
5255 const fieldPath = propRef . path
5356
5457 // Ensure index exists for this field
@@ -79,11 +82,7 @@ function getOrderedKeys<T extends object, TKey extends string | number>(
7982 // Take the keys that match the filter and limit
8083 // if no limit is provided `index.keyCount` is used,
8184 // i.e. we will take all keys that match the filter
82- return index . take (
83- limit ?? index . keyCount ,
84- undefined ,
85- filterFn
86- ) as Array < TKey >
85+ return index . take ( limit ?? index . keyCount , undefined , filterFn )
8786 }
8887 }
8988 }
@@ -134,7 +133,7 @@ function getOrderedKeys<T extends object, TKey extends string | number>(
134133 */
135134function extractValueFromItem ( item : any , expression : BasicExpression ) : any {
136135 if ( expression . type === `ref` ) {
137- const propRef = expression as PropRef
136+ const propRef = expression
138137 let value = item
139138 for ( const pathPart of propRef . path ) {
140139 value = value ?. [ pathPart ]
@@ -223,7 +222,7 @@ export function currentStateAsChanges<
223222 options . orderBy ,
224223 options . limit ,
225224 whereFilter ,
226- options . optimizedOnly ,
225+ options . optimizedOnly
227226 )
228227
229228 if ( orderedKeys === undefined ) {
0 commit comments