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#
IndexInterface<TKey>
Constructors#
Constructor#
new BaseIndex<TKey>(
id,
expression,
name?,
options?): BaseIndex<TKey>;
Defined in: packages/db/src/indexes/base-index.ts:139
Parameters#
id#
number
expression#
name?#
string
options?#
any
Returns#
BaseIndex<TKey>
Properties#
compareFn()#
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#
protected readonly compareOptions: CompareOptions;
Defined in: packages/db/src/indexes/base-index.ts:125
expression#
readonly expression: BasicExpression;
Defined in: packages/db/src/indexes/base-index.ts:123
hasCustomComparator#
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#
readonly id: number;
Defined in: packages/db/src/indexes/base-index.ts:121
name?#
readonly optional name: string;
Defined in: packages/db/src/indexes/base-index.ts:122
supportedOperations#
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#
get abstract keyCount(): number;
Defined in: packages/db/src/indexes/base-index.ts:181
Returns#
number
Implementation of#
supportsRangeOptimization#
Get Signature#
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()#
abstract add(key, item): void;
Defined in: packages/db/src/indexes/base-index.ts:157
Parameters#
key#
TKey
item#
any
Returns#
void
Implementation of#
addRangeValue()#
protected addRangeValue(value): void;
Defined in: packages/db/src/indexes/base-index.ts:209
Parameters#
value#
unknown
Returns#
void
build()#
abstract build(entries): void;
Defined in: packages/db/src/indexes/base-index.ts:160
Parameters#
entries#
Iterable<[TKey, any]>
Returns#
void
Implementation of#
canOptimizeRangeFor()#
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()#
abstract clear(): void;
Defined in: packages/db/src/indexes/base-index.ts:161
Returns#
void
Implementation of#
clearRangeValues()#
protected clearRangeValues(): void;
Defined in: packages/db/src/indexes/base-index.ts:227
Returns#
void
equalityLookup()#
abstract equalityLookup(value): Set<TKey>;
Defined in: packages/db/src/indexes/base-index.ts:182
Parameters#
value#
any
Returns#
Set<TKey>
Implementation of#
evaluateIndexExpression()#
protected evaluateIndexExpression(item): any;
Defined in: packages/db/src/indexes/base-index.ts:299
Parameters#
item#
any
Returns#
any
inArrayLookup()#
abstract inArrayLookup(values): Set<TKey>;
Defined in: packages/db/src/indexes/base-index.ts:183
Parameters#
values#
any[]
Returns#
Set<TKey>
Implementation of#
initialize()#
abstract protected initialize(options?): void;
Defined in: packages/db/src/indexes/base-index.ts:297
Parameters#
options?#
any
Returns#
void
lookup()#
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#
matchesCompareOptions()#
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()#
matchesDirection(direction): boolean;
Defined in: packages/db/src/indexes/base-index.ts:293
Checks if the index matches the provided direction.
Parameters#
direction#
Returns#
boolean
Implementation of#
IndexInterface.matchesDirection
matchesField()#
matchesField(fieldPath): boolean;
Defined in: packages/db/src/indexes/base-index.ts:241
Parameters#
fieldPath#
string[]
Returns#
boolean
Implementation of#
rangeQuery()#
abstract rangeQuery(options): Set<TKey>;
Defined in: packages/db/src/indexes/base-index.ts:184
Parameters#
options#
Returns#
Set<TKey>
Implementation of#
rangeQueryReversed()#
rangeQueryReversed(options): Set<TKey>;
Defined in: packages/db/src/indexes/base-index.ts:187
Parameters#
options#
Returns#
Set<TKey>
Implementation of#
IndexInterface.rangeQueryReversed
remove()#
abstract remove(key, item): void;
Defined in: packages/db/src/indexes/base-index.ts:158
Parameters#
key#
TKey
item#
any
Returns#
void
Implementation of#
removeRangeValue()#
protected removeRangeValue(value): void;
Defined in: packages/db/src/indexes/base-index.ts:218
Parameters#
value#
unknown
Returns#
void
supports()#
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#
take()#
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#
takeFromStart()#
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#
takeReversed()#
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#
takeReversedFromEnd()#
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()#
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