Load the first entity matching the conjunction of field equality operands and query modifiers.
This is a convenience method for loadManyByFieldEqualityConjunctionAsync. However, the orderBy query modifier is required to ensure consistent results if more than one entity matches the filters.
the first entity matching the filters, or null if none match
Load entities matching the conjunction of field equality operands and query modifiers.
Typically this is used for complex queries that cannot be expressed through simpler convenience methods such as loadManyByFieldEqualingAsync.
entities matching the filters
Load entities with a raw SQL WHERE clause.
SQL WHERE clause. Interpolated values should be specified as ?-placeholders or :key_name
values to bind to the placeholders in the WHERE clause
limit, offset, and orderBy for the query. If orderBy is specified as orderByRaw, specify as string orderBy SQL clause with uncheckd literal values or ?-placeholders
entities matching the WHERE clause
Load entities with SQL function
const entitiesWithJsonKey = await ExampleEntity.loader(vc)
.loadManyByRawWhereClauseAsync(
"json_column->>'key_name' = ?",
['value'],
);
Load entities with tuple matching
const entities = await ExampleEntity.loader(vc)
.loadManyByRawWhereClauseAsync(
'(column_1, column_2) IN ((?, ?), (?, ?))',
[value1, value2, value3, value4],
);
Load entities using a SQL query builder. When executed, all queries will enforce authorization and throw if not authorized.
const entities = await ExampleEntity.loader(vc)
.loadManyBySQL(sql`age >= ${18} AND status = ${'active'}`)
.orderBy('createdAt', 'DESC')
.limit(10)
.executeAsync();
const { between, inArray } = SQLFragmentHelpers;
const filtered = await ExampleEntity.loader(vc)
.loadManyBySQL(
sql`${between('age', 18, 65)} AND ${inArray('role', ['admin', 'moderator'])}`
)
.executeAsync();
Load a page of entities with Relay-style cursor pagination.
Pagination arguments with pagination and either first/after or last/before
a page of entities matching the pagination arguments
Enforcing knex entity loader for non-data-loader-based load methods. All loads through this loader will throw if the load is not successful.