-
Notifications
You must be signed in to change notification settings - Fork 1
Query utilities
Radosław Mejer edited this page May 9, 2020
·
1 revision
Fetch the record using the primaryKey
.
const jon = await User.find(1)
Similar to fetch()
with one difference - when record is not found a ModelNotFound
error will be thrown.
const jon = await User.findOrFail(1)
Return the first matching result. If none found, throw ModelNotFound
error.
const jon = await User.where({ active: true, name: 'Jon' })
.firstOrFail()