Skip to main content

KeyworkDatabase

Overview

Creates a database instance backed by a Cloudflare KV namespace.

Usage

import { KeyworkDatabase } from 'keywork/collections'

Constructors

constructor

new KeyworkDatabase

(kvNamespace)

Parameters

NameTypeDescription
kvNamespaceKVNamespace<string>

Defined in

collections/KeyworkDatabase.ts:24

Properties

kvNamespace

protected kvNamespace: `KVNamespace<string>`

The KV namespace binding provided by the parent Worker.

Defined in

collections/KeyworkDatabase.ts:26

Methods

collection

collection

(collectionPath): `Promise<[`KeyworkCollection<{} | [`DeserializationTypes`](../types/DeserializationTypes.mdx)>`](KeyworkCollection.mdx)>`

Gets a KeyworkCollection instance that refers to a collection of documents.

Parameters

NameType
collectionPathstring

Returns

Promise<[KeyworkCollection<{} | DeserializationTypes>](/modules/collections/classes/KeyworkCollection)>

Defined in

collections/KeyworkDatabase.ts:42

doc

doc

doc<ExpectedType>(docPath): [`KeyworkDocumentReference<`ExpectedType`>`](KeyworkDocumentReference.mdx)

Gets a KeyworkDocumentReference instance that refers to the document at the specified absolute path.

Type parameters

NameType
ExpectedTypeextends {}

Parameters

NameType
docPathstring

Returns

KeyworkDocumentReference<ExpectedType>

Defined in

collections/KeyworkDatabase.ts:32