Options
All
  • Public
  • Public/Protected
  • All
Menu

jinedb

Index

Type aliases

Awaitable

Awaitable<T>: T | Promise<T>

A value that can be await-ed to produce a T

Type parameters

  • T

Dict

Dict<V>: Partial<Record<string, V>>

Record<string, V>, but does not assume that a value exists for each key.

Type parameters

  • V

    Type of values

Indexable

Indexable: NativelyIndexable | { [encodesTo]: Indexable | NativelyIndexable }

Types that Jine can use to index database items

Migration

Migration: (genuine: boolean, tx: MigrationTx) => Promise<void>

A database migration.

A migration is a function that is given a Transaction and is allowed to do as it pleases with it. Migrations have special access to Transaction.addStore, Transaction.removeStore, Store.addIndex, and Store.removeIndex to allow you to change the shape of your database. Additionally, migrations are not allowed to access store indexes.

See Example for example use of a Migration.

Type declaration

    • Parameters

      Returns Promise<void>

MigrationTx

MigrationTx: Transaction<{}>

The database shape during migrations.

The essential meaning of this is that items access during migrations will not be encoded or decoded, and indexes are not available during migrations.

NativelyIndexable

NativelyIndexable: undefined | null | boolean | string | number | Date | ArrayBuffer | ArrayBufferView | ImageBitmap | ImageData | Array<NativelyIndexable>

Types that are natively indexable by Jine.

The types are ordered as follows:

undefined < null < false < true < number < date < string < binary < array

Also note the following:

  • A number may not be NaN

  • A Date object's internal [[DateValue]] slot may not be NaN

  • Jine doesn't support all numbers; a small handful of very large negative numbers will be snapped to slightly higher (less negative) values.

NativelyStorable

NativelyStorable: undefined | null | string | number | boolean | BigInt | Date | RegExp | Blob | File | FileList | ArrayBuffer | ArrayBufferView | ImageBitmap | ImageData | Array<NativelyStorable> | PlainObjectOf<NativelyStorable> | Map<NativelyStorable, NativelyStorable> | Set<NativelyStorable>

Types that are natively storable by Jine

Note that the lastIndex property of a RegExp is not preserved.

Query

Query<Trait>: "all" | { above?: Trait; below?: Trait; equals?: Trait; from?: Trait; reversed?: undefined | false | true; through?: Trait; unique?: undefined | false | true }

Query specification

A query falls into one of 3 categories:

Wildcard: A wildcard query selects everything. This is given by 'all'.

Exact: An exact query selects a particular value. This is given by { equals: value }.

Range: A range query selects values within a particular range. The range may be bounded below or above, or both, but not neither. Both bounds may be inclusive or exclusive. Lower bounds are given by the keys from and above, for inclusive and exclusive, respectively; likewise, upper bounds are given by keywords through and below. Thus { from: 0, below: 10 } represents 0 <= x < 10 and { through: 3 } represents x <= 3.

Additionally, a query may have the reversed and unique keys. reversed marks that the query results should be traversed in reverse order, and unique marks that duplicated values should be skipped.

Type parameters

Storable

Storable: NativelyStorable | { [encodesTo]: Storable | PlainObjectOf<NativelyStorable> }

Types that Jine can store in the database

TransactionMode

TransactionMode: "r" | "rw" | "m"

Modes that a transaction can take.

r - Read only. Multiple read-only transactions can occur on the same stores at the same time.

rw - Read and write. A read-write transaction will block accessed stores until it is complete.

m - Migration. A migration transaction will block an entire database from use until it is complete.

Variables

Const encodesTo

encodesTo: keyof symbol

Typescript users must declare this attribute on any custom-encodable classes. The value should be the type that the class encodes to.

Functions

codec

  • codec<Decoded, Encoded>(type: Constructor<unknown>, id: string, code: {}): UserCodec<Decoded, Encoded>

Generated using TypeDoc