Kadak

Quick Start

Define one table and run the full CRUD flow safely.

Quick Start

You want to go from zero to working CRUD without learning the full API first.

1. Define one table

import { table, kadak } from '@shyk/kadak-orm'

export const users = table('users', {
  id: 'id',
  email: 'email',
  name: 'text',
  age: 'int?',
  balance: kadak.decimal(),
  isActive: 'boolean',
}, {
  timestamps: true,
  softDelete: true,
})

2. Connect

import { connect } from '@shyk/kadak-orm'
import { users } from './schema'

export const db = connect('postgres://postgres:postgres@localhost:5432/kadak_demo', { users })

3. CRUD

const created = await db.users.insert({
  email: 'riya@example.com',
  name: 'Riya',
  isActive: true,
  balance: '100.00',
})

const rows = await db.users.findMany({ $limit: 10, $order: { createdAt: 'desc' } })

await db.users.update({ id: created.id }, { isActive: false })
await db.users.delete({ id: created.id })

4. Validate request bodies

const parsed = users.insertValidator().safeParse({
  email: 'dev@example.com',
  name: 'Dev',
  isActive: true,
  balance: '5.00',
})

if (parsed.success) {
  await db.users.insert(parsed.data)
}

Important: validate input on the server even if the frontend already validates.

Next: Find Many, Insert, Update, Delete.

On this page