Skip to main content
Module

x/kvdex/mod.ts>Collection

Database wrapper for Deno KV
Go to Latest
class Collection
Re-export
import { Collection } from "https://deno.land/x/kvdex@v0.1.2/mod.ts";

Constructors

new
Collection(kv: Deno.Kv, collectionKey: KvKey)

Represents a collection of documents stored in the KV store.

Contains methods to work on documents in the collection.

Properties

protected
kv: Deno.Kv
readonly
collectionIdKey: KvKey

Methods

add(data: T)

Adds a new document to the KV store with a randomely generated id.

Deletes a document with the given id from the KV store.

Deletes multiple documents from the KV store according to the given options.

If no options are given, all documents are deleted.

find(id: KvId, options?: FindOptions)

Finds a document with the given id in the KV store.

findMany(ids: KvId[], options?: FindManyOptions)

Finds multiple documents with the given array of ids in the KV store.

forEach(fn: (doc: Document<T>) => void, options?: ListOptions<T>)

Executes a callback function for every document according to the given options.

If no options are given, the callback function is executed for all documents in the collection.

getMany(options?: ListOptions<T>)

Retrieves multiple documents from the KV store according to the given options.

If no options are given, all documents are retrieved.

set(id: KvId, data: T)

Adds a new document with the given id to the KV store.