DeesseJS Collections

Getting Started

Get up and running with Collections in minutes

Getting Started

Get up and running with @deessejs/collections in minutes.

Installation

Install the required dependencies:

npm install @deessejs/collections @deessejs/cli drizzle-orm zod

Your First Collection

Create your first collection in a dedicated file:

// collections/users.ts
import { collection, field } from '@deessejs/collections'
import { text, email } from '@deessejs/collections/fields'

export const users = collection({
  slug: 'users',

  label: 'User',
  plural: 'Users',

  fields: {
    name: field({
      type: text({ min: 2, max: 100 }),
      label: 'Name'
    }),
    email: field({
      type: email(),
      unique: true,
      label: 'Email'
    })
  }
})

Configuration

Set up your database and collections:

// config/database.ts
import { defineConfig } from '@deessejs/collections'
import { users } from '../collections/users'

export const { collections, db } = defineConfig({
  database: {
    url: process.env.DATABASE_URL!
  },

  collections: [users]
})

Generate Migrations

Generate and run your database migrations:

npx @deessejs/cli generate
npx @deessejs/cli migrate

These commands are wrappers around drizzle-kit that automatically detect your configuration.

Start Using Collections

Now you can use your collections with full type safety:

// Create a user
const user = await collections.users.create({
  data: {
    name: 'John Doe',
    email: 'john@example.com'
  }
})

// Find users
const users = await collections.users.findMany({
  where: {
    email: { equals: 'john@example.com' }
  }
})

// Update a user
await collections.users.update({
  where: { id: user.id },
  data: { name: 'Jane Doe' }
})

Next Steps

  • CLI - Learn about migration commands and database management
  • Core Concepts - Learn about configuration, collections, and fields
  • Field Types - Explore available field types
  • Collections - Advanced features like relations and hooks

On this page