Overview of Lucid Models
A Lucid model is a TypeScript class that maps to a database table using the Active Record pattern. Each model instance represents a single row. Models provide a typed way to query data, persist records, and implement lifecycle hooks, relationships, computed properties, and serialization rules. Use the database query builder directly only for one-off reports, scripts, or complex joins that project columns not defined on a single model.
import User from '#models/user'
const user = await User.findOrFail(1)
user.email = 'virk@adonisjs.com'
await user.save()