KeyworkDocumentReference
Overview
Usage
- Node
- Deno
- Browser/ESM
import { KeyworkDocumentReference } from 'keywork/collections'
import { KeyworkDocumentReference } from 'https://deno.land/x/keywork/collections'
let { KeyworkDocumentReference } = await import('https://esm.sh/keywork/collections')
Type parameters
| Name | Type |
|---|---|
ExpectedType | extends DeserializationTypes |
Constructors
constructor
new KeyworkDocumentReference
new KeyworkDocumentReference<ExpectedType>(kvNamespace, relativeDocPath, parentCollection?)
Type parameters
| Name | Type |
|---|---|
ExpectedType | extends {} |
Parameters
| Name | Type | Description |
|---|---|---|
kvNamespace | KVNamespace<string> | |
relativeDocPath | string | |
parentCollection? | KeyworkCollection<ExpectedType> | - |
Defined in
collections/KeyworkDocumentReference.ts:64
Properties
absoluteDocPath
readonly absoluteDocPath: `string`
A POSIX-style, absolute path to a document.
Defined in
collections/KeyworkDocumentReference.ts:62
kvNamespace
protected readonly kvNamespace: `KVNamespace<string>`
The KV namespace binding provided by the parent Worker.
Defined in
collections/KeyworkDocumentReference.ts:66
parentCollection
protected optional readonly parentCollection: [`KeyworkCollection<`ExpectedType`>`](KeyworkCollection.mdx)
Defined in
collections/KeyworkDocumentReference.ts:69
relativeDocPath
readonly relativeDocPath: `string`
A POSIX-style, relative path to a document from a parent collection
Defined in
collections/KeyworkDocumentReference.ts:59
Methods
fetchSnapshot
fetchSnapshot
(options?): `Promise<[`KeyworkDocumentSnapshot<`ExpectedType`>`](../types/KeyworkDocumentSnapshot.mdx)>`
Attempts to fetch a KeyworkDocumentSnapshot associated with the docPath.
If the deserializeAs option is not set,
the type will attempt to be inferred from the parent collection's known metadata.
Parameters
| Name | Type |
|---|---|
options? | KeyworkDocumentFetchOptions |
Returns
Promise<[KeyworkDocumentSnapshot<ExpectedType>](/modules/collections/types/KeyworkDocumentSnapshot)>
Defined in
collections/KeyworkDocumentReference.ts:83
patchValue
patchValue
patchValue<E>(nextValue, options?, snapshot?, deepMergeOptions?): `Promise<[`KeyworkDocumentReference<`ExpectedType`>`](KeyworkDocumentReference.mdx)>`
Updates the data associated with this document's path.
Type parameters
| Name | Type |
|---|---|
E | ExpectedType |
Parameters
| Name | Type | Description |
|---|---|---|
nextValue | Partial<E> | |
options? | PutOrPatchOptions | - |
snapshot? | KeyworkDocumentSnapshot<E> | |
deepMergeOptions? | any |
Returns
Promise<[KeyworkDocumentReference<ExpectedType>](/modules/collections/classes/KeyworkDocumentReference)>
Defined in
collections/KeyworkDocumentReference.ts:178
putValue
putValue
putValue<E>(nextValue, putOptions?): `Promise<[`KeyworkDocumentReference<`ExpectedType`>`](KeyworkDocumentReference.mdx)>`
Overwrites the entire entity if it already exists, and creates a new resource if it doesn’t exist.
Type parameters
| Name | Type |
|---|---|
E | ExpectedType |
Parameters
| Name | Type |
|---|---|
nextValue | Partial<E> |
putOptions? | PutOrPatchOptions |
Returns
Promise<[KeyworkDocumentReference<ExpectedType>](/modules/collections/classes/KeyworkDocumentReference)>
Defined in
collections/KeyworkDocumentReference.ts:126
Creates an instance associated with specific document within a Cloudflare KV.