Defined in: packages/db/src/indexes/btree-index.ts:44
B+Tree index for sorted data with range queries This maintains items in sorted order and provides efficient range operations
TKey extends string | number = string | number
new BTreeIndex<TKey>(
id,
expression,
name?,
options?): BTreeIndex<TKey>;Defined in: packages/db/src/indexes/btree-index.ts:67
number
string
any
BTreeIndex<TKey>
protected compareOptions: CompareOptions;Defined in: packages/db/src/indexes/base-index.ts:122
readonly expression: BasicExpression;Defined in: packages/db/src/indexes/base-index.ts:120
protected hasCustomComparator: boolean = false;Defined in: packages/db/src/indexes/base-index.ts:128
Set by subclasses when constructed with a user-supplied comparator, whose ordering may not match the WHERE evaluator's relational operators.
readonly id: number;Defined in: packages/db/src/indexes/base-index.ts:118
readonly optional name: string;Defined in: packages/db/src/indexes/base-index.ts:119
readonly supportedOperations: Set<"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike">;Defined in: packages/db/src/indexes/btree-index.ts:47
get keyCount(): number;Defined in: packages/db/src/indexes/btree-index.ts:277
Gets the number of indexed keys
number
get supportsRangeOptimization(): boolean;Defined in: packages/db/src/indexes/base-index.ts:193
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.
boolean
BaseIndex.supportsRangeOptimization
add(key, item): void;Defined in: packages/db/src/indexes/btree-index.ts:98
Adds a value to the index
TKey
any
void
protected addRangeValue(value): void;Defined in: packages/db/src/indexes/base-index.ts:197
unknown
void
build(entries): void;Defined in: packages/db/src/indexes/btree-index.ts:225
Builds the index from a collection of entries
Iterable<[TKey, any]>
void
canOptimizeRangeFor(value): boolean;Defined in: packages/db/src/indexes/base-index.ts:219
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.
unknown
boolean
clear(): void;Defined in: packages/db/src/indexes/btree-index.ts:236
Clears all data from the index
void
protected clearRangeValues(): void;Defined in: packages/db/src/indexes/base-index.ts:215
void
equalityLookup(value): Set<TKey>;Defined in: packages/db/src/indexes/btree-index.ts:286
Performs an equality lookup
any
Set<TKey>
protected evaluateIndexExpression(item): any;Defined in: packages/db/src/indexes/base-index.ts:276
any
any
BaseIndex.evaluateIndexExpression
inArrayLookup(values): Set<TKey>;Defined in: packages/db/src/indexes/btree-index.ts:431
Performs an IN array lookup
any[]
Set<TKey>
protected initialize(_options?): void;Defined in: packages/db/src/indexes/btree-index.ts:93
BTreeIndexOptions
void
lookup(operation, value): Set<TKey>;Defined in: packages/db/src/indexes/btree-index.ts:246
Performs a lookup operation
"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"
any
Set<TKey>
matchesCompareOptions(compareOptions): boolean;Defined in: packages/db/src/indexes/base-index.ts:241
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.
CompareOptions
boolean
BaseIndex.matchesCompareOptions
matchesDirection(direction): boolean;Defined in: packages/db/src/indexes/base-index.ts:270
Checks if the index matches the provided direction.
boolean
matchesField(fieldPath): boolean;Defined in: packages/db/src/indexes/base-index.ts:229
string[]
boolean
rangeQuery(options): Set<TKey>;Defined in: packages/db/src/indexes/btree-index.ts:295
Performs a range query with options This is more efficient for compound queries like "WHERE a > 5 AND a < 10"
Set<TKey>
rangeQueryReversed(options): Set<TKey>;Defined in: packages/db/src/indexes/base-index.ts:175
Set<TKey>
remove(key, item): void;Defined in: packages/db/src/indexes/btree-index.ts:146
Removes a value from the index
TKey
any
void
protected removeRangeValue(value): void;Defined in: packages/db/src/indexes/base-index.ts:206
unknown
void
supports(operation): boolean;Defined in: packages/db/src/indexes/base-index.ts:189
"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"
boolean
take(
n,
from,
filterFn?): TKey[];Defined in: packages/db/src/indexes/btree-index.ts:377
Returns the next n items after the provided item.
number
The number of items to return
any
The item to start from (exclusive).
(key) => boolean
TKey[]
The next n items after the provided key.
takeFromStart(n, filterFn?): TKey[];Defined in: packages/db/src/indexes/btree-index.ts:390
Returns the first n items from the beginning.
number
The number of items to return
(key) => boolean
Optional filter function
TKey[]
The first n items
takeReversed(
n,
from,
filterFn?): TKey[];Defined in: packages/db/src/indexes/btree-index.ts:402
Returns the next n items before the provided item (in descending order).
number
The number of items to return
any
The item to start from (exclusive). Required.
(key) => boolean
TKey[]
The next n items before the provided key.
takeReversedFromEnd(n, filterFn?): TKey[];Defined in: packages/db/src/indexes/btree-index.ts:419
Returns the last n items from the end.
number
The number of items to return
(key) => boolean
Optional filter function
TKey[]
The last n items
update(
key,
oldItem,
newItem): void;Defined in: packages/db/src/indexes/btree-index.ts:192
Updates a value in the index
TKey
any
any
void