Defined in: packages/db/src/indexes/basic-index.ts:39
Basic index using Map + sorted Array.
Map for O(1) equality lookups
Sorted Array for O(log n) range queries via binary search
O(n) updates to maintain sort order
Simpler and smaller than BTreeIndex, good for read-heavy workloads. Use BTreeIndex for write-heavy workloads with large collections.
BaseIndex<TKey>
TKey extends string | number = string | number
new BasicIndex<TKey>(
id,
expression,
name?,
options?): BasicIndex<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:60
number
string
any
BasicIndex<TKey>
protected compareOptions: CompareOptions;Defined in: packages/db/src/indexes/base-index.ts:101
readonly expression: BasicExpression;Defined in: packages/db/src/indexes/base-index.ts:95
protected hasCustomComparator: boolean = false;Defined in: packages/db/src/indexes/base-index.ts:106
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:93
protected lastUpdated: Date;Defined in: packages/db/src/indexes/base-index.ts:100
protected lookupCount: number = 0;Defined in: packages/db/src/indexes/base-index.ts:98
readonly optional name: string;Defined in: packages/db/src/indexes/base-index.ts:94
readonly supportedOperations: Set<"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike">;Defined in: packages/db/src/indexes/basic-index.ts:42
protected totalLookupTime: number = 0;Defined in: packages/db/src/indexes/base-index.ts:99
get indexedKeysSet(): Set<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:485
Set<TKey>
get keyCount(): number;Defined in: packages/db/src/indexes/basic-index.ts:239
Gets the number of indexed keys
number
get orderedEntriesArray(): [any, Set<TKey>][];Defined in: packages/db/src/indexes/basic-index.ts:489
[any, Set<TKey>][]
get orderedEntriesArrayReversed(): [any, Set<TKey>][];Defined in: packages/db/src/indexes/basic-index.ts:496
[any, Set<TKey>][]
BaseIndex.orderedEntriesArrayReversed
get supportsRangeOptimization(): boolean;Defined in: packages/db/src/indexes/base-index.ts:161
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
get valueMapData(): Map<any, Set<TKey>>;Defined in: packages/db/src/indexes/basic-index.ts:505
Map<any, Set<TKey>>
add(key, item): void;Defined in: packages/db/src/indexes/basic-index.ts:79
Adds a value to the index
TKey
any
void
build(entries): void;Defined in: packages/db/src/indexes/basic-index.ts:157
Builds the index from a collection of entries
Iterable<[TKey, any]>
void
clear(): void;Defined in: packages/db/src/indexes/basic-index.ts:194
Clears all data from the index
void
equalityLookup(value): Set<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:246
Performs an equality lookup - O(1)
any
Set<TKey>
protected evaluateIndexExpression(item): any;Defined in: packages/db/src/indexes/base-index.ts:212
any
any
BaseIndex.evaluateIndexExpression
getStats(): IndexStats;Defined in: packages/db/src/indexes/base-index.ts:200
inArrayLookup(values): Set<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:470
Performs an IN array lookup - O(k) where k is values.length
any[]
Set<TKey>
protected initialize(_options?): void;Defined in: packages/db/src/indexes/basic-index.ts:74
void
lookup(operation, value): Set<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:204
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:177
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:196
Checks if the index matches the provided direction.
boolean
matchesField(fieldPath): boolean;Defined in: packages/db/src/indexes/base-index.ts:165
string[]
boolean
rangeQuery(options): Set<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:254
Performs a range query using binary search - O(log n + m)
RangeQueryOptions = {}
Set<TKey>
rangeQueryReversed(options): Set<TKey>;Defined in: packages/db/src/indexes/basic-index.ts:315
Performs a reversed range query
RangeQueryOptions = {}
Set<TKey>
remove(key, item): void;Defined in: packages/db/src/indexes/basic-index.ts:115
Removes a value from the index
TKey
any
void
supports(operation): boolean;Defined in: packages/db/src/indexes/base-index.ts:157
"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"
boolean
take(
n,
from?,
filterFn?): TKey[];Defined in: packages/db/src/indexes/basic-index.ts:340
Returns the next n items in sorted order
number
any
(key) => boolean
TKey[]
takeFromStart(n, filterFn?): TKey[];Defined in: packages/db/src/indexes/basic-index.ts:425
Returns the first n items in sorted order (from the start)
number
(key) => boolean
TKey[]
takeReversed(
n,
from?,
filterFn?): TKey[];Defined in: packages/db/src/indexes/basic-index.ts:382
Returns the next n items in reverse sorted order
number
any
(key) => boolean
TKey[]
takeReversedFromEnd(n, filterFn?): TKey[];Defined in: packages/db/src/indexes/basic-index.ts:444
Returns the first n items in reverse sorted order (from the end)
number
(key) => boolean
TKey[]
protected trackLookup(startTime): void;Defined in: packages/db/src/indexes/base-index.ts:217
number
void
update(
key,
oldItem,
newItem): void;Defined in: packages/db/src/indexes/basic-index.ts:149
Updates a value in the index
TKey
any
any
void
protected updateTimestamp(): void;Defined in: packages/db/src/indexes/base-index.ts:223
void