Skip to main content
Module

x/kvdex/mod.ts>CollectionBuilder

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

Builder object for building new collections of documents.

Constructors

new
CollectionBuilder(kv: Deno.Kv)

Create a new CollectionBuilder instance for building collections.

Properties

private
collectionKeyStrs: string[]
private
kv: Deno.Kv

Methods

private
checkCollectionKey(collectionKey: KvKey)
collection<T extends KvValue>(collectionKey: KvKey)

Create a standard collection of data adhering to the type KvValue. Can be of primitives, like strings and numbers, or arrays and objects.

Example:

builder.collection<string>(["strings"])
indexableCollection<T extends Model>(collectionKey: KvKey)

Create an indexable collection of data adhering to the type Model. Restricted to object types.

Example:

builder.indexableCollection<User>(["users"], {
  username: "primary",
  age: "secondary"
})