Skip to content

Query utilities

Radosław Mejer edited this page May 9, 2020 · 1 revision

find()

Fetch the record using the primaryKey.

const jon = await User.find(1)

findOrFail()

Similar to fetch() with one difference - when record is not found a ModelNotFound error will be thrown.

const jon = await User.findOrFail(1)

firstOrFail()

Return the first matching result. If none found, throw ModelNotFound error.

const jon = await User.where({ active: true, name: 'Jon' })
  .firstOrFail()
Clone this wiki locally