Skip to content

Documentation / @warp-drive/experiments / document-storage / DocumentStorage

Defined in: document-storage/index.ts:407

DocumentStorage is a wrapper around the StorageManager API that provides a simple interface for reading and updating documents and requests.

Some goals for this experiment:

  • optimize for storing requests/documents
  • optimize for storing resources
  • optimize for looking up resources associated to a document
  • optimize for notifying cross-tab when data is updated

optional features:

  • support for offline mode
  • ?? support for relationship based cache traversal
  • a way to index records by type + another field (e.g updatedAt/createAt/name) such that simple queries can be done without having to scan all records

Constructors

Constructor

ts
new DocumentStorage(options): DocumentStorage;

Defined in: document-storage/index.ts:410

Parameters

options

Partial<DocumentStorageOptions> = {}

Returns

DocumentStorage

Properties

_storage

ts
readonly _storage: InternalDocumentStorage;

Defined in: document-storage/index.ts:408

Methods

clear()

ts
clear(reset?): Promise<void>;

Defined in: document-storage/index.ts:448

Parameters

reset?

boolean

Returns

Promise<void>


getDocument()

ts
getDocument(key): Promise<null | CacheDocument>;

Defined in: document-storage/index.ts:430

Parameters

key

DocumentIdentifier

Returns

Promise<null | CacheDocument>


putDocument()

ts
putDocument(document, resourceCollector): Promise<void>;

Defined in: document-storage/index.ts:434

Parameters

document

CacheFileDocument

resourceCollector

(resourceIdentifier) => ExistingResourceObject

Returns

Promise<void>


putResources()

ts
putResources(document, resourceCollector): Promise<void>;

Defined in: document-storage/index.ts:441

Parameters

document

ResourceDataDocument<ExistingRecordIdentifier<string>>

resourceCollector

(resourceIdentifier) => ExistingResourceObject

Returns

Promise<void>

Released under the MIT License.