- Core API Reference
- Collection
- createCollection
- liveQueryCollectionOptions
- createLiveQueryCollection
- createOptimisticAction
- createTransaction
- Electric DB Collection
- electricCollectionOptions
- Query DB Collection
- queryCollectionOptions
- RxDB DB Collection
- rxdbCollectionOptions
- PowerSync Collection
- powerSyncCollectionOptions
- createIndexedDB
- indexedDBCollectionOptions
- React Hooks
- useLiveQuery
BaseIndex
Defined in: packages/db/src/indexes/base-index.ts:137
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:158
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:149
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:144
expression#
readonly expression: BasicExpression;Defined in: packages/db/src/indexes/base-index.ts:142
hasCustomComparator#
protected readonly hasCustomComparator: boolean;Defined in: packages/db/src/indexes/base-index.ts:155
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:140
name?#
readonly optional name: string;Defined in: packages/db/src/indexes/base-index.ts:141
supportedOperations#
readonly supportedOperations: Set<"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike">;Defined in: packages/db/src/indexes/base-index.ts:143
Accessors#
keyCount#
Get Signature#
get abstract keyCount(): number;Defined in: packages/db/src/indexes/base-index.ts:203
Returns#
number
Implementation of#
supportsOrderOptimization#
Get Signature#
get supportsOrderOptimization(): boolean;Defined in: packages/db/src/indexes/base-index.ts:259
Whether a query can use this index for its declared ordered prefix.
Returns#
boolean
Whether a query can use this index for its declared ordered prefix.
Implementation of#
IndexInterface.supportsOrderOptimization
supportsRangeOptimization#
Get Signature#
get supportsRangeOptimization(): boolean;Defined in: packages/db/src/indexes/base-index.ts:255
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:179
Parameters#
key#
TKey
item#
any
Returns#
void
Implementation of#
addRangeValue()#
protected addRangeValue(value): void;Defined in: packages/db/src/indexes/base-index.ts:277
Parameters#
value#
unknown
Returns#
void
build()#
abstract build(entries): void;Defined in: packages/db/src/indexes/base-index.ts:182
Parameters#
entries#
Iterable<[TKey, any]>
Returns#
void
Implementation of#
canOptimizeRangeFor()#
canOptimizeRangeFor(value): boolean;Defined in: packages/db/src/indexes/base-index.ts:299
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:183
Returns#
void
Implementation of#
clearRangeValues()#
protected clearRangeValues(): void;Defined in: packages/db/src/indexes/base-index.ts:295
Returns#
void
equalityLookup()#
abstract equalityLookup(value): Set<TKey>;Defined in: packages/db/src/indexes/base-index.ts:204
Parameters#
value#
any
Returns#
Set<TKey>
Implementation of#
evaluateAddedValue()#
protected evaluateAddedValue(key, item): any;Defined in: packages/db/src/indexes/base-index.ts:374
The indexed value of a row being added. A throwing expression fails the write.
Parameters#
key#
TKey
item#
any
Returns#
any
evaluateIndexExpression()#
protected evaluateIndexExpression(item): any;Defined in: packages/db/src/indexes/base-index.ts:367
Parameters#
item#
any
Returns#
any
exactBucketKeys()#
protected exactBucketKeys(value): Iterable<TKey, any, any> | undefined;Defined in: packages/db/src/indexes/base-index.ts:205
Parameters#
value#
any
Returns#
Iterable<TKey, any, any> | undefined
inArrayLookup()#
inArrayLookup(values): Set<TKey>;Defined in: packages/db/src/indexes/base-index.ts:228
Combine exact buckets without copying each bucket first.
Parameters#
values#
any[]
Returns#
Set<TKey>
Implementation of#
initialize()#
protected initialize(_options?): void;Defined in: packages/db/src/indexes/base-index.ts:365
Parameters#
_options?#
any
Returns#
void
lookup()#
abstract lookup(operation, value): Set<TKey>;Defined in: packages/db/src/indexes/base-index.ts:184
Parameters#
operation#
"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"
value#
any
Returns#
Set<TKey>
Implementation of#
lookupSupportedOperation()#
protected lookupSupportedOperation(operation, value): Set<TKey> | undefined;Defined in: packages/db/src/indexes/base-index.ts:211
Parameters#
operation#
"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike"
value#
any
Returns#
Set<TKey> | undefined
matchesCompareOptions()#
matchesCompareOptions(compareOptions): boolean;Defined in: packages/db/src/indexes/base-index.ts:321
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:361
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:309
Parameters#
fieldPath#
string[]
Returns#
boolean
Implementation of#
rangeQuery()#
abstract rangeQuery(options): Set<TKey>;Defined in: packages/db/src/indexes/base-index.ts:208
Parameters#
options#
Returns#
Set<TKey>
Implementation of#
rangeQueryReversed()#
rangeQueryReversed(options): Set<TKey>;Defined in: packages/db/src/indexes/base-index.ts:237
Parameters#
options#
RangeQueryOptions = {}
Returns#
Set<TKey>
Implementation of#
IndexInterface.rangeQueryReversed
remove()#
abstract remove(key, item): void;Defined in: packages/db/src/indexes/base-index.ts:180
Parameters#
key#
TKey
item#
any
Returns#
void
Implementation of#
removeRangeValue()#
protected removeRangeValue(value): void;Defined in: packages/db/src/indexes/base-index.ts:286
Parameters#
value#
unknown
Returns#
void
supports()#
supports(operation): boolean;Defined in: packages/db/src/indexes/base-index.ts:251
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:185
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:190
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:194
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:199
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:181
Parameters#
key#
TKey
oldItem#
any
newItem#
any
Returns#
void