Skip to main content

Class: default

Defined in: src/lib/documentStore/index.ts:95

Keeps whole documents in the browser's IndexedDB database (DOCUMENT_DATABASE_NAME), under a name (e.g. to keep each user's apart): each document in one record, and its summary in another, so they can be listed without loading their layers.

Example​

const store = new IndexedDbDocumentStore("ada.example", { label: "This browser" });
await store.save(await canvas.createDocument());
const [latest] = await store.list();
await canvas.openDocument((await store.load(latest.id))!);
await store.markOpened(latest.id);

Implements​

Constructors​

Constructor​

new default(name?, __namedParameters?): IndexedDbDocumentStore

Defined in: src/lib/documentStore/index.ts:107

Parameters​

name?​

string = DEFAULT_DOCUMENT_STORE_NAME

the name the documents are kept under (DEFAULT_DOCUMENT_STORE_NAME by default)

__namedParameters?​

IndexedDbDocumentStoreOptions = {}

Returns​

IndexedDbDocumentStore

Properties​

label?​

readonly optional label?: string

Defined in: src/lib/documentStore/index.ts:98

Names the store for the user, e.g. "Bluesky" (shown while saving)

Implementation of​

DocumentListStoreLike.label


name​

readonly name: string

Defined in: src/lib/documentStore/index.ts:96

Methods​

list()​

list(): Promise<DocumentSummary[]>

Defined in: src/lib/documentStore/index.ts:136

The saved documents in short, most recently opened first

Returns​

Promise<DocumentSummary[]>

Implementation of​

DocumentListStoreLike.list


load()​

load(id): Promise<DrawingDocument | undefined>

Defined in: src/lib/documentStore/index.ts:129

A saved document by ID, or undefined if there's none

Parameters​

id​

string

Returns​

Promise<DrawingDocument | undefined>

Implementation of​

DocumentListStoreLike.load


markOpened()​

markOpened(id, date?): Promise<void>

Defined in: src/lib/documentStore/index.ts:155

Mark a saved document opened at a time (now by default), without counting it as changed (updatedAt)

Parameters​

id​

string

date?​

Date = ...

Returns​

Promise<void>

Implementation of​

DocumentListStoreLike.markOpened


remove()​

remove(id): Promise<void>

Defined in: src/lib/documentStore/index.ts:147

Delete a saved document

Parameters​

id​

string

Returns​

Promise<void>

Implementation of​

DocumentListStoreLike.remove


save()​

save(document, onProgress?): Promise<void>

Defined in: src/lib/documentStore/index.ts:116

Save a document, replacing the one with the same ID. Call onProgress with how much is done (0 to 1), if known.

Parameters​

document​

DrawingDocument

onProgress?​

(done) => void

Returns​

Promise<void>

Implementation of​

DocumentListStoreLike.save