C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

Back to Learning Center
Intermediate
30 min

Database & ORM

Connect to databases and use the built-in ORM.

Database & ORM

CanxJS comes with a lightweight yet powerful ORM that supports MySQL, PostgreSQL, and SQLite.

Configuration

Database configuration lives in src/config/database.ts:

typescript
export default {
  default: "mysql",
  connections: {
    mysql: {
      driver: "mysql",
      host: process.env.DB_HOST,
      user: process.env.DB_USER,
      // ...
    }
  }
}

Creating Models

Generate a model:

bash
bun run canx make:model User

Using the Query Builder

typescript
import { DB } from "canxjs";

// Fetch all users
const users = await DB.table("users").get();

// Filtering
const activeUsers = await DB.table("users")
    .where("status", "active")
    .orderBy("created_at", "desc")
    .get();

Eloquent-style Models

typescript
import { User } from "./models/User";

const user = await User.find(1);
user.name = "Updated Name";
await user.save();

Have questions?

Join the discussion on GitHub