Introduction
Bob is a "database-first" ORM. That means you must first create your database schema. Please use something like sql-migrate or some other migration tool to manage this part of the database's life-cycle.
There is also a generator for other schema definitions like Atlas' schema and Prisma's schema.
Available Drivers
Sources | Driver |
---|---|
PostgreSQL | LINK |
MySQL | LINK |
SQLite | LINK |
Atlas | LINK |
Prisma | LINK |
Features
- Full model generation
- Generates factories for easy testing
- Extremely fast code generation
- High performance through generation & intelligent caching
- Uses bob.Executor (simple interface, sql.DB, sql.Tx, sqlx.DB etc. compatible)
- Uses context.Context
- Easy workflow (models can always be regenerated, full auto-complete)
- Strongly typed querying (usually no converting or binding to pointers)
- Hooks (Before/After Select/Insert/Update/Delete/Upsert)
- Table and column filtering for generation
- Custom struct tags
- Raw SQL fallback
- Cross-schema support
- 1d arrays, json, hstore & more
- Enum types
- Support for database views
- Supports generated/computed columns
- Multi-column foreign key support
- Relationships/Associations
- Eager loading (recursive)
- Automatically detects relationships based on foreign keys
- Can load related models both by a left-join and a 2nd query
- Supports user-configured relationships
- Can configure relationships based on static column values. For example, (
WHERE object_type = 'car' AND object_id = cars.id
) - Support for
has-one-through
andhas-many-through
.
📄️ Configuration
How to configure Bob's code generation
📄️ Usage
How to use the Generated Models
📄️ Relationships
Working with relationships
📄️ Factories
Using model factories to speed up testing
📄️ Enums
Generated code for defined Enums
📄️ PostgreSQL Driver
ORM Generation for PostgreSQL
📄️ MySQL Driver
ORM Generation for MySQL
📄️ SQLite Driver
ORM Generation for SQLite
📄️ Atlas Driver
ORM Generation for Atlas
📄️ Prisma Driver
ORM Generation for Prisma
📄️ Ignored features
Features ignored by Bob