Skip to content

Latest commit

 

History

History
518 lines (299 loc) · 9.47 KB

OPFSDB.md

File metadata and controls

518 lines (299 loc) · 9.47 KB

opfsdb / Exports / OPFSDB

Class: OPFSDB<T>

Type parameters

Name Type
T extends IBasicRecord

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new OPFSDB<T>(tableName, keys?, order?, defaultKey?): OPFSDB<T>

Type parameters

Name Type
T extends IBasicRecord

Parameters

Name Type Default value
tableName string undefined
keys? ITableKeys undefined
order number 25
defaultKey undefined | string undefined

Returns

OPFSDB<T>

Defined in

lib/OPFSDB.ts:18

Properties

defaultKey

Private defaultKey: undefined | string

Defined in

lib/OPFSDB.ts:22


encoder

Private encoder: IEncoder

Defined in

lib/OPFSDB.ts:14


handles

Private handles: Map<FileSystemDirectoryHandle, Map<string, FileSystemSyncAccessHandle>>

Defined in

lib/OPFSDB.ts:16


holesIndex

Private holesIndex: BPTreeAsync<number, number>

Defined in

lib/OPFSDB.ts:10


keys

Private Optional keys: ITableKeys

Defined in

lib/OPFSDB.ts:20


lastIndex

Private lastIndex: number

Defined in

lib/OPFSDB.ts:15


order

Private order: number = 25

Defined in

lib/OPFSDB.ts:21


recordsIndex

Private recordsIndex: BPTreeAsync<Uint8Array, string>

Defined in

lib/OPFSDB.ts:9


recordsRoot

Private recordsRoot: FileSystemDirectoryHandle

Defined in

lib/OPFSDB.ts:13


root

Private root: FileSystemDirectoryHandle

Defined in

lib/OPFSDB.ts:12


tableName

Private tableName: string

Defined in

lib/OPFSDB.ts:19


trees

Private trees: Record<string, BPTreeAsync<string, string | number>> = {}

Defined in

lib/OPFSDB.ts:11

Methods

cleanupHole

cleanupHole(hole, encodedLength, encodedEndIndex): Promise<void>

Parameters

Name Type
hole void | [number, number]
encodedLength number
encodedEndIndex number

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:139


createOrFindHandle

createOrFindHandle(dir, fileName, create?): Promise<FileSystemSyncAccessHandle>

Parameters

Name Type Default value
dir FileSystemDirectoryHandle undefined
fileName string undefined
create boolean false

Returns

Promise<FileSystemSyncAccessHandle>

Defined in

lib/OPFSDB.ts:278


decodeLocation

decodeLocation(val?): number[]

Parameters

Name Type
val? Uint8Array

Returns

number[]

Defined in

lib/OPFSDB.ts:300


delete

delete(id, oldRecord?): Promise<void>

Parameters

Name Type
id string
oldRecord? T

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:242


drop

drop(): Promise<void>

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:258


encodeLocation

encodeLocation(at, length): Uint8Array

Parameters

Name Type
at number
length number

Returns

Uint8Array

Defined in

lib/OPFSDB.ts:296


getHole

getHole(size): Promise<void | [number, number]>

Parameters

Name Type
size number

Returns

Promise<void | [number, number]>

Defined in

lib/OPFSDB.ts:130


import

import(records): Promise<void>

Parameters

Name Type
records { id: string ; value: T }[]

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:149


init

init(): Promise<void>

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:25


insert

insert(id, value, fullRecord?): Promise<void>

Parameters

Name Type
id string
value T
fullRecord? boolean

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:175


query

query(queries, options?): Promise<string[] | T[]>

Parameters

Name Type
queries { [key in string | number | symbol]?: Partial<Object> }
options? IQueryOptions

Returns

Promise<string[] | T[]>

Defined in

lib/OPFSDB.ts:71


read

read(id): Promise<void | T>

Parameters

Name Type
id string

Returns

Promise<void | T>

Defined in

lib/OPFSDB.ts:122


readFile

readFile(dir, fileName, from?, encoder?, to?): Promise<any>

Parameters

Name Type Default value
dir FileSystemDirectoryHandle undefined
fileName string undefined
from number 0
encoder? false | IEncoder undefined
to? number undefined

Returns

Promise<any>

Defined in

lib/OPFSDB.ts:305


readMany

readMany(ids): Promise<T[]>

Parameters

Name Type
ids string[]

Returns

Promise<T[]>

Defined in

lib/OPFSDB.ts:109


unload

unload(): void

Returns

void

Defined in

lib/OPFSDB.ts:268


writeFile

writeFile(dir, fileName, data, encoder?, at?, pageSize?): Promise<void>

Parameters

Name Type Default value
dir FileSystemDirectoryHandle undefined
fileName string undefined
data Record<string, any> | Uint8Array undefined
encoder? false | IEncoder undefined
at number 0
pageSize? number undefined

Returns

Promise<void>

Defined in

lib/OPFSDB.ts:341