Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

findIndexForField.md

44 lines783 Bytes

1---
2id: findIndexForField
3title: findIndexForField
4---
5​
6```ts
7function findIndexForField<TKey>(
8 collection,
9 fieldPath,
10 compareOptions?,
11 canUse?): IndexReader<TKey> | undefined;
12```
13​
14Defined in: [packages/db/src/utils/index-optimization.ts:59](https://github.com/TanStack/db/blob/main/packages/db/src/utils/index-optimization.ts#L59)
15​
16Finds the first usable index matching a field path and comparison options.
17​
18## Type Parameters
19​
20### TKey
21​
22`TKey` *extends* `string` \| `number`
23​
24## Parameters
25​
26### collection
27​
28[`CollectionLike`](../interfaces/CollectionLike.md)\<`any`, `TKey`\>
29​
30### fieldPath
31​
32`string`[]
33​
34### compareOptions?
35​
36`CompareOptions`
37​
38### canUse?
39​
40(`index`) => `boolean`
41​
42## Returns
43​
44[`IndexReader`](../type-aliases/IndexReader.md)\<`TKey`\> \| `undefined`