Skip to main content

Quick Start Guide

Get started with ChameleonDB in 5 minutes.

Prerequisites

Before you begin, ensure you have:
  • Go 1.21+ installed
  • PostgreSQL 14+ running
  • Terminal access (bash, zsh, or PowerShell)

Installation

See the Installation Guide for detailed instructions on Linux, macOS, and Windows. Quick install:
Verify installation:

Your First ChameleonDB Project

1

Initialize Project

Create a new directory and initialize ChameleonDB:
What happens:
  • Creates .chameleon/ directory
  • Initializes Schema Vault
  • Creates default schema.cham
  • Sets mode to readonly
Output:
2

Define Your Schema

Edit schema.cham to define your data model:
schema.cham
Validate your schema:
Output:
3

Configure Database Connection

Set your PostgreSQL connection string:
Replace user, password, and mydb with your actual PostgreSQL credentials.
4

Run Migration

Apply your schema to the database:
Output:
Use --dry-run flag to preview SQL without applying: chameleon migrate --dry-run
5

Use in Your Application

Initialize a Go module and add ChameleonDB:
Create main.go:
main.go
Run your application:
Output:

Query with Relations

ChameleonDB makes it easy to query related data:
Using Include() prevents N+1 query problems by eagerly loading related data. ChameleonDB’s IdentityMap automatically deduplicates objects in memory.

Debug Mode

See the generated SQL for any query:
Output:

Schema Vault Commands

ChameleonDB tracks every schema change in the Schema Vault:

Example: View Version History

Integrity Modes

ChameleonDB uses integrity modes to control who can modify schemas:
In readonly mode (the default), schema modifications are blocked. Upgrade to standard mode for development.

Common Issues

Solution: Run chameleon init in your project directory.
Solution: Upgrade to standard mode.
Solution: Check what changed and view the audit log.
Solution: Set the environment variable.

Next Steps

Installation Guide

Detailed installation for Linux, macOS, and Windows

CLI Reference

Complete guide to all CLI commands

Query API

Type-safe query and mutation reference

Examples

Real-world example applications

What You’ve Learned

  • βœ… How to initialize ChameleonDB projects
  • βœ… How to define schemas in .cham files
  • βœ… How to run migrations with the Schema Vault
  • βœ… How to query data with the Go SDK
  • βœ… How to use Debug mode to see SQL
  • βœ… How to manage integrity modes

Getting Help