BaseIndex

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

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:140

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:131

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:126


expression

ts
readonly expression: BasicExpression;

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


hasCustomComparator

ts
protected readonly hasCustomComparator: boolean;

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

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:122


name?

ts
readonly optional name: string;

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


supportedOperations

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

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

Accessors

keyCount

Get Signature

ts
get abstract keyCount(): number;

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

Returns

number

Implementation of

IndexInterface.keyCount


supportsRangeOptimization

Get Signature

ts
get supportsRangeOptimization(): boolean;

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

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:158

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:210

Parameters

value

unknown

Returns

void


build()

ts
abstract build(entries): void;

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

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:232

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:162

Returns

void

Implementation of

IndexInterface.clear


clearRangeValues()

ts
protected clearRangeValues(): void;

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

Returns

void


equalityLookup()

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

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

Parameters

value

any

Returns

Set<TKey>

Implementation of

IndexInterface.equalityLookup


evaluateAddedValue()

ts
protected evaluateAddedValue(key, item): any;

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

The indexed value of a row being added. A throwing expression fails the write.

Parameters

key

TKey

item

any

Returns

any


evaluateIndexExpression()

ts
protected evaluateIndexExpression(item): any;

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

Parameters

item

any

Returns

any


inArrayLookup()

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

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

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:298

Parameters

options?

any

Returns

void


lookup()

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

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

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:254

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:294

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:242

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:185

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:188

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:159

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:219

Parameters

value

unknown

Returns

void


supports()

ts
supports(operation): boolean;

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

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:164

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:169

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:173

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:178

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:160

Parameters

key

TKey

oldItem

any

newItem

any

Returns

void

Implementation of

IndexInterface.update