?
db.filter
Return all rows matching a predicate. Use the bindings form so the predicate compiles to SQL instead of scanning every row.
Table.filter(predicate, bindings?) → Query<T[]>
Returns every row matching a predicate. Reference only the row and literal values and the predicate compiles straight to a SQL WHERE clause; reference an input, the current user, or any other outer-scope value and you must pass it through the bindings argument, or the whole predicate falls back to fetching the table and filtering in memory — a warning is logged when that happens. Build a query up progressively, one clause per optional argument, and chain .sortBy, .take, and .skip off the result.
Parameters
predicate
(row, $) => boolean
RequiredArrow function compiled to a SQL WHERE clause.
bindings
object
Outer-scope values lifted so the filter compiles to SQL.
Filter with bindings
const approved = await Vendors.filter( (v, $) => v.status === $.status, { status: 'approved' }, // bindings: compiles to SQL );