Skip to main content
Module

x/kvdex/mod.ts>collection

High-level abstraction layer for Deno KV 🦕📁
Go to Latest
function collection
import { collection } from "https://deno.land/x/kvdex@v0.29.0/mod.ts";

Create a new collection within a database context.

Examples

Example 1

import { model, collection, kvdex } from "https://deno.land/x/kvdex/mod.ts"

type User = {
  username: string
  age: number
}

const db = kvdex(kv, {
  numbers: collection(model<number>()),
  users: collection(model<User>(), {
    idGenerator: () => crypto.randomUUID(),
    serialized: true,
    indices: {
      username: "primary",
      age: "secondary"
    }
  })
})

Type Parameters

TInput
TOutput extends KvValue
TOptions extends CollectionOptions<TOutput>

Parameters

  • Collection model.
optional
options: TOptions
  • Collection options.