Getting Started
Welcome to Flash ORM! This guide will help you get up and running in minutes.
Prerequisites
- Go 1.24.2+ (for Go projects)
- Node.js 22+ (for TypeScript/JavaScript projects)
- Python 3.9+ (for Python projects)
- Database: PostgreSQL, MySQL, SQLite, or MongoDB
Installation
Option 1: NPM (Recommended for all platforms)
bash
npm install -g flashormOption 2: Python
bash
pip install flashormOption 3: Go
bash
go install github.com/Lumos-Labs-HQ/flash@latestOption 4: Download Binary
Download the latest release from GitHub Releases.
Quick Start
1. Initialize Your Project
Choose your database and initialize:
bash
# For PostgreSQL (default)
flash init --postgresql
# For MySQL
flash init --mysql
# For SQLite
flash init --sqlite2. Project Structure
The flash init command creates the following structure:
your-project/
├── flash.config.json # Configuration file
├── db/
│ ├── schema/ # SQL schema files
│ │ └── schema.sql # Your database schema
│ ├── queries/ # SQL query files
│ │ └── users.sql # Your database queries
│ ├── migrations/ # Generated migrations
│ └── export/ # Export directory
├── flash_gen/ # Generated code (after flash gen)
└── .env # Environment variables3. Configure Database
Edit the .env file with your database connection:
env
# PostgreSQL
DATABASE_URL=postgres://user:password@localhost:5432/yourdb
# MySQL
DATABASE_URL=user:password@tcp(localhost:3306)/yourdb
# SQLite
DATABASE_URL=sqlite://./data.db3. Define Your Schema
Edit db/schema/schema.sql:
sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
title VARCHAR(255) NOT NULL,
content TEXT,
published BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);4. Create and Apply Migration
bash
# Create migration
flash migrate "initial schema"
# Apply to database
flash apply5. Generate Code
bash
flash genLanguage-Specific Guides
Choose your preferred language:
- Go Guide - Type-safe Go code generation
- TypeScript Guide - JavaScript/TypeScript with full type support
- Python Guide - Async Python with type hints
Next Steps
- Learn about Core Concepts
- Explore Database Support
- Check out FlashORM Studio for visual database management
- Read about Migrations and Branching