?
db.findOne
Return the first row matching a predicate, or null.
Table.findOne(predicate, bindings?) → Query<T | null>
Returns the first row that satisfies the predicate, or null when none do. Pass any outer-scope value it compares against through the bindings argument so the match runs as SQL instead of scanning the table. Use it when you expect one row, and db.filter when you want them all.
Parameters
predicate
(row, $) => boolean
RequiredCompiled to a SQL WHERE clause.
bindings
object
Outer-scope values lifted so the match compiles to SQL.
Find with bindings
const admin = await Users.findOne( (u, $) => u.email === $.email, { email }, // bindings: compiles to SQL );