first
The first method returns the first record found in the given table.
const user = await User.first()
// User{id=1}
select "users".* from "users" order by "users"."id" asc nulls first limit $1
Chaining
Similar to other execution methods, first can be chained with other chainable query methods, such as order.
await User.order({ email: 'asc' }).first()
select "users".* from "users" order by "users"."email" asc nulls first limit 1
tip
In some cases, firstOrFail may be more ideal, since it will raise a RecordNotFound exception, causing the request to fail with a 404 error automatically.