Columns are field pointers, not strings. Write ant.Gt(&Users.Age, 18) and the compiler checks both the column and the value. Rename a field and every query follows.
type User struct {
ant.Base // ID, CreatedAt, UpdatedAt
Name string
Age int
Posts []Post // 1:N through Post.UserID
}
type Post struct {
ant.Base
UserID int64
Title string
}
type AppDB struct {
ant.Context
Users ant.Table[User]
Posts ant.Table[Post]
}
var Users = ant.Fields[User]()
db, err := ant.Open[AppDB](ctx, postgres.Dialect, dsn) // shared, tracks nothing
session := ant.Session(db) // one unit of work, such as a request
adults, err := session.Users.
Where(ant.Gt(&Users.Age, 18)). // ant.Gt(&Users.Age, "18") won't compile
Include(&Users.Posts). // one batched query, not one per user
All(ctx)
adults[0].Age++
err = session.SaveChanges(ctx) // writes only the columns that changed