API Reference
Symbol-level documentation for Quark's public API: signatures, parameters, and exact behaviour, grouped the same way the sidebar is.
Use these pages when you know what you want to call and need the details. If you are still working out how to do something, the Guides cover the same ground as walkthroughs.
Core API
- Client - Creating and configuring the ORM client
- Query Builder - Fluent type-safe query construction
- CRUD - Create, Read, Update, Delete operations
- Querying - Retrieving data: List, Find, aggregates, pagination
Model Definition
- Modeling - Struct tags, relations, hooks
Schema & Data
- Transactions - ACID transactions and savepoints
- Migrations - Schema migrations and sync
Advanced Features
- Caching - Query result caching with Redis/Memory
- Multi-Tenant - Row-level, schema, and database isolation
- Observability - Middleware, OpenTelemetry, events
Reference
- Dialects - Database dialect interface
- Errors - Error types and handling
- Routines - Stored procedures and functions
Quick Example
package main
import (
"context"
_ "github.com/lib/pq"
"github.com/jcsvwinston/quark"
)
type User struct {
ID int64 `db:"id" pk:"true"`
Name string `db:"name"`
Email string `db:"email" quark:"unique"`
}
func main() {
client, _ := quark.New("postgres", "...")
ctx := context.Background()
// Create
user := &User{Name: "Alice", Email: "alice@example.com"}
quark.For[User](ctx, client).Create(user)
// => user.ID is populated with the generated primary key
// Read
u, _ := quark.For[User](ctx, client).Find(user.ID)
// => u is the matching User; err is quark.ErrNotFound if no row exists
// Query
users, _ := quark.For[User](ctx, client).
Where("active", "=", true).
OrderBy("created_at", "DESC").
List()
// => users is a []User of active rows, newest first
// Update
u.Name = "Alice Smith"
quark.For[User](ctx, client).Update(&u)
// => returns (rowsAffected int64, err error)
// Delete
quark.For[User](ctx, client).Delete(&u)
// => returns (rowsAffected int64, err error)
}