A reactive computed index that provides efficient lookups of records by property values. Returns a computed value containing an RSIndexMap with diffs for change tracking.

type RSIndex<
  R extends UnknownRecord,
  Property extends string & keyof R = string & keyof R,
> = Computed<RSIndexMap<R, Property>, RSIndexDiff<R, Property>>

Example

// Create an index on book authors
const authorIndex: RSIndex<Book, 'authorId'> = store.query.index(
  'book',
  'authorId'
)

// Get all books by a specific author
const leguinBooks = authorIndex.get().get('author:leguin')
Prev
RecordScope
Next
RSIndexDiff