MCPcopy Create free account
hub / github.com/TanStack/db / createIndex

Method createIndex

packages/db/src/collection/index.ts:598–603  ·  view source on GitHub ↗

* Creates an index on a collection for faster queries. * Indexes significantly improve query performance by allowing constant time lookups * and logarithmic time range queries instead of full scans. * * @param indexCallback - Function that extracts the indexed value from each item * @

(
    indexCallback: (row: SingleRowRefProxy<TOutput>) => any,
    config: IndexOptions<TIndexType> = {},
  )

Source from the content-addressed store, hash-verified

596 * ```
597 */
598 public createIndex<TIndexType extends IndexConstructor<TKey>>(
599 indexCallback: (row: SingleRowRefProxy<TOutput>) => any,
600 config: IndexOptions<TIndexType> = {},
601 ): BaseIndex<TKey> {
602 return this._indexes.createIndex(indexCallback, config)
603 }
604
605 /**
606 * Removes an index created with createIndex.

Calls

no outgoing calls

Tested by 1