Skip to main content
Module

x/kvdex/mod.ts>model

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

Create a standard model without data validation.

Optionally provide a transform function.

Examples

Example 1

type User = {
  username: string
  age: number
  createdAt: Date
}

// Normal model
const UserModel = model<User>()

// Transform model
const UserModel = model<Omit<User, "createdAt">, User>((user) => ({
  ...user,
  createdAt: new Date()
}))

Type Parameters

optional
TInput = unknown
optional
TOutput extends KvValue = TInput extends KvValue ? TInput : KvValue

Parameters

optional
transform: (data: TInput) => TOutput
  • Transform function mapping from input data to output data.

Returns

A standard model.