KeyworkCollection
Overview
Usage
- Node
- Deno
- Browser/ESM
import { KeyworkCollection } from 'keywork/collections'
import { KeyworkCollection } from 'https://deno.land/x/keywork/collections'
let { KeyworkCollection } = await import('https://esm.sh/keywork/collections')
Type parameters
Name | Type |
---|---|
ExpectedType | extends DeserializationTypes |
Constructors
constructor
new KeyworkCollection
new KeyworkCollection<ExpectedType>(kvNamespace, collectionPath)
Type parameters
Name | Type |
---|---|
ExpectedType | extends {} |
Parameters
Name | Type | Description |
---|---|---|
kvNamespace | KVNamespace<string> | |
collectionPath | string |
Defined in
collections/KeyworkCollection.ts:75
Properties
collectionPath
collectionPath: `string`
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
Name | Type |
---|---|
E | extends {} |
Parameters
Name | Type |
---|---|
entry | E |
metadata | KeyworkDocumentMetadata |
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
Name | Type |
---|---|
relativeDocPath | string |
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
Name | Type |
---|---|
relativeDocPath | string |
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
Name | Type |
---|---|
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
Name | Type |
---|---|
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
Name | Type |
---|---|
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
A slash-separated path to a collection.