TanStack

BaseIndex

Defined in: packages/db/src/indexes/base-index.ts:118

Base abstract class that all index types extend

Extended by

Type Parameters

TKey

TKey extends string | number = string | number

Implements

Constructors

Constructor

ts
new BaseIndex<TKey>(
   id, 
   expression, 
   name?, 
options?): BaseIndex<TKey>;

Defined in: packages/db/src/indexes/base-index.ts:139

Parameters

id

number

expression

BasicExpression

name?

string

options?

any

Returns

BaseIndex<TKey>

Properties

compareFn()

ts
protected readonly compareFn: (a, b) => number;

Defined in: packages/db/src/indexes/base-index.ts:130

Orders indexed values. Every result is checked, because a custom comparator or custom collation may be supplied by the user.

Parameters

a

any

b

any

Returns

number


compareOptions

ts
protected readonly compareOptions: CompareOptions;

Defined in: packages/db/src/indexes/base-index.ts:125


expression

ts
readonly expression: BasicExpression;

Defined in: packages/db/src/indexes/base-index.ts:123


hasCustomComparator

ts
protected readonly hasCustomComparator: boolean;

Defined in: packages/db/src/indexes/base-index.ts:136

A user-supplied comparator's ordering may not match the WHERE evaluator's relational operators.


id

ts
readonly id: number;

Defined in: packages/db/src/indexes/base-index.ts:121


name?

ts
readonly optional name: string;

Defined in: packages/db/src/indexes/base-index.ts:122


supportedOperations

ts
abstract readonly supportedOperations: Set<"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike">;

Defined in: packages/db/src/indexes/base-index.ts:124

Accessors

keyCount

Get Signature

ts
get abstract keyCount(): number;

Defined in: packages/db/src/indexes/base-index.ts:181

Returns

number

Implementation of

IndexInterface.keyCount


supportsRangeOptimization

Get Signature

ts
get supportsRangeOptimization(): boolean;

Defined in: packages/db/src/indexes/base-index.ts:205

Whether range lookups (gt/gte/lt/lte) on this index can be trusted to return every matching key. Range traversal relies on the index ordering, so it is unsafe when the index uses a custom comparator, whose order may not match the WHERE evaluator's relational operators. Callers must fall back to a full scan when this is false.

Returns

boolean

Implementation of

IndexInterface.supportsRangeOptimization

Methods

add()

ts
abstract add(key, item): void;

Defined in: packages/db/src/indexes/base-index.ts:157

Parameters

key

TKey

item

any

Returns

void

Implementation of

IndexInterface.add


addRangeValue()

ts
protected addRangeValue(value): void;

Defined in: packages/db/src/indexes/base-index.ts:209

Parameters

value

unknown

Returns

void


build()

ts
abstract build(entries): void;

Defined in: packages/db/src/indexes/base-index.ts:160

Parameters

entries

Iterable<[TKey, any]>

Returns

void

Implementation of

IndexInterface.build


canOptimizeRangeFor()

ts
canOptimizeRangeFor(value): boolean;

Defined in: packages/db/src/indexes/base-index.ts:231

Whether the live values in this index share the predicate operand's relational domain. Mixed domains can sort differently in the index and WHERE evaluator, which can make a range lookup omit matching rows.

Parameters

value

unknown

Returns

boolean

Implementation of

IndexInterface.canOptimizeRangeFor


clear()

ts
abstract clear(): void;

Defined in: packages/db/src/indexes/base-index.ts:161

Returns

void

Implementation of

IndexInterface.clear


clearRangeValues()

ts
protected clearRangeValues(): void;

Defined in: packages/db/src/indexes/base-index.ts:227

Returns

void


equalityLookup()

ts
abstract equalityLookup(value): Set<TKey>;

Defined in: packages/db/src/indexes/base-index.ts:182

Parameters

value

any

Returns

Set<TKey>

Implementation of

IndexInterface.equalityLookup


evaluateIndexExpression()

ts
protected evaluateIndexExpression(item): any;

Defined in: packages/db/src/indexes/base-index.ts:299

Parameters

item

any

Returns

any


inArrayLookup()

ts
abstract inArrayLookup(values): Set<TKey>;

Defined in: packages/db/src/indexes/base-index.ts:183

Parameters

values

any[]

Returns

Set<TKey>

Implementation of

IndexInterface.inArrayLookup


initialize()

ts
abstract protected initialize(options?): void;

Defined in: packages/db/src/indexes/base-index.ts:297

Parameters

options?

any

Returns

void


lookup()

ts
abstract lookup(operation, value): Set<TKey>;

Defined in: packages/db/src/indexes/base-index.ts:162

Parameters

operation

"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"

value

any

Returns

Set<TKey>

Implementation of

IndexInterface.lookup


matchesCompareOptions()

ts
matchesCompareOptions(compareOptions): boolean;

Defined in: packages/db/src/indexes/base-index.ts:253

Checks if the compare options match the index's compare options. The direction is ignored because the index can be reversed if the direction is different.

Parameters

compareOptions

CompareOptions

Returns

boolean

Implementation of

IndexInterface.matchesCompareOptions


matchesDirection()

ts
matchesDirection(direction): boolean;

Defined in: packages/db/src/indexes/base-index.ts:293

Checks if the index matches the provided direction.

Parameters

direction

OrderByDirection

Returns

boolean

Implementation of

IndexInterface.matchesDirection


matchesField()

ts
matchesField(fieldPath): boolean;

Defined in: packages/db/src/indexes/base-index.ts:241

Parameters

fieldPath

string[]

Returns

boolean

Implementation of

IndexInterface.matchesField


rangeQuery()

ts
abstract rangeQuery(options): Set<TKey>;

Defined in: packages/db/src/indexes/base-index.ts:184

Parameters

options

BTreeRangeQueryOptions

Returns

Set<TKey>

Implementation of

IndexInterface.rangeQuery


rangeQueryReversed()

ts
rangeQueryReversed(options): Set<TKey>;

Defined in: packages/db/src/indexes/base-index.ts:187

Parameters

options

BTreeRangeQueryOptions = {}

Returns

Set<TKey>

Implementation of

IndexInterface.rangeQueryReversed


remove()

ts
abstract remove(key, item): void;

Defined in: packages/db/src/indexes/base-index.ts:158

Parameters

key

TKey

item

any

Returns

void

Implementation of

IndexInterface.remove


removeRangeValue()

ts
protected removeRangeValue(value): void;

Defined in: packages/db/src/indexes/base-index.ts:218

Parameters

value

unknown

Returns

void


supports()

ts
supports(operation): boolean;

Defined in: packages/db/src/indexes/base-index.ts:201

Parameters

operation

"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"

Returns

boolean

Implementation of

IndexInterface.supports


take()

ts
abstract take(
   n, 
   from, 
   filterFn?): TKey[];

Defined in: packages/db/src/indexes/base-index.ts:163

Parameters

n

number

from

unknown

filterFn?

(key) => boolean

Returns

TKey[]

Implementation of

IndexInterface.take


takeFromStart()

ts
abstract takeFromStart(n, filterFn?): TKey[];

Defined in: packages/db/src/indexes/base-index.ts:168

Parameters

n

number

filterFn?

(key) => boolean

Returns

TKey[]

Implementation of

IndexInterface.takeFromStart


takeReversed()

ts
abstract takeReversed(
   n, 
   from, 
   filterFn?): TKey[];

Defined in: packages/db/src/indexes/base-index.ts:172

Parameters

n

number

from

unknown

filterFn?

(key) => boolean

Returns

TKey[]

Implementation of

IndexInterface.takeReversed


takeReversedFromEnd()

ts
abstract takeReversedFromEnd(n, filterFn?): TKey[];

Defined in: packages/db/src/indexes/base-index.ts:177

Parameters

n

number

filterFn?

(key) => boolean

Returns

TKey[]

Implementation of

IndexInterface.takeReversedFromEnd


update()

ts
abstract update(
   key, 
   oldItem, 
   newItem): void;

Defined in: packages/db/src/indexes/base-index.ts:159

Parameters

key

TKey

oldItem

any

newItem

any

Returns

void

Implementation of

IndexInterface.update