Skip to main content

KeyworkCollection

Overview

Usage

import { KeyworkCollection } from 'keywork/collections'

Type parameters

NameType
ExpectedTypeextends DeserializationTypes

Constructors

constructor

new KeyworkCollection

new KeyworkCollection<ExpectedType>(kvNamespace, collectionPath)

Type parameters

NameType
ExpectedTypeextends {}

Parameters

NameTypeDescription
kvNamespaceKVNamespace<string>
collectionPathstring

Defined in

collections/KeyworkCollection.ts:75

Properties

collectionPath

collectionPath: `string`

A slash-separated path to a collection.

Defined in

collections/KeyworkCollection.ts:79

kvNamespace

protected kvNamespace: `KVNamespace<string>`

The KV namespace binding provided by the parent Worker.

Defined in

collections/KeyworkCollection.ts:77

Methods

addEntryToIndexes

addEntryToIndexes

addEntryToIndexes<E>(entry, metadata): `Promise<void>`

Type parameters

NameType
Eextends {}

Parameters

NameType
entryE
metadataKeyworkDocumentMetadata

Returns

Promise<void>

Defined in

collections/KeyworkCollection.ts:184

createDocumentReference

createDocumentReference

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

Create a KeyworkDocumentReference instance that refers to the document at the specified relative path.

Parameters

NameType
relativeDocPathstring

Returns

KeyworkDocumentReference<ExpectedType>

Defined in

collections/KeyworkCollection.ts:175

fetchDocumentMetadataByPath

fetchDocumentMetadataByPath

(relativeDocPath): `Promise<`null` | [`KeyworkDocumentMetadata`](../interfaces/KeyworkDocumentMetadata.mdx)>`

Fetches a given document's metadata. This is used to determine a document's deserialization ahead of its fetching.

Parameters

NameType
relativeDocPathstring

Returns

Promise<null | [KeyworkDocumentMetadata](/modules/collections/interfaces/KeyworkDocumentMetadata)>

Defined in

collections/KeyworkCollection.ts:139

fetchDocuments

fetchDocuments

(options?): `Promise<[`CollectionDocumentReferencesResponse<`ExpectedType`>`](../interfaces/CollectionDocumentReferencesResponse.mdx)>`

Fetches a paginated list of the immediate KeyworkDocumentReference.

Parameters

NameType
options?FetchListOptions

Returns

Promise<[CollectionDocumentReferencesResponse<ExpectedType>](/modules/collections/interfaces/CollectionDocumentReferencesResponse)>

Defined in

collections/KeyworkCollection.ts:146

fetchDocumentsList

fetchDocumentsList

(options?): `Promise<{ `cursor?`: `string` ; `keys`: (`undefined` | `string`)[] ; `list_complete`: `boolean`  }>`

Parameters

NameType
options?FetchListOptions

Returns

Promise<{ cursor?: string;keys: (undefined|string)[] ; list_complete: boolean }>

Defined in

collections/KeyworkCollection.ts:126

fetchDocumentsListByID

fetchDocumentsListByID

(options?): `Promise<`KVNamespaceListResult<[`KeyworkDocumentMetadata`](../interfaces/KeyworkDocumentMetadata.mdx)>`>`

Fetches a paginated list of the immediate documents within this collection.

Parameters

NameType
options?FetchListOptions

Returns

Promise<KVNamespaceListResult<KeyworkDocumentMetadata>>

Defined in

collections/KeyworkCollection.ts:119

fetchIndexPrefixes

Protected fetchIndexPrefixes

(): `Promise<string[]>`

Returns

Promise<string[]>

Defined in

collections/KeyworkCollection.ts:107

initialize

initialize

(): `Promise<[`KeyworkCollection<`ExpectedType`>`](KeyworkCollection.mdx)>`

Returns

Promise<[KeyworkCollection<ExpectedType>](/modules/collections/classes/KeyworkCollection)>

Defined in

collections/KeyworkCollection.ts:88

permanentlyDeleteThisCollection

permanentlyDeleteThisCollection

(): `void`

Returns

void

Defined in

collections/KeyworkCollection.ts:236

query

query

(): `void`

Returns

void

Defined in

collections/KeyworkCollection.ts:232