Count entities matching the conjunction of field equality operands. This does not perform authorization since count does not load full entities. Note that this should be used with the same caution as loadManyByFieldEqualityConjunctionAsync regarding indexing since counts can be expensive on large datasets without appropriate indexes.
count of entities matching the filters
Count entities matching a SQL fragment. This does not perform authorization since count does not load full entity rows. Note that this should be used with the same caution as loadManyBySQL regarding indexing since counts can be expensive on large datasets without appropriate indexes.
count of entities matching the query
Get cursor for a given entity that matches what loadPageAsync would produce. Useful for constructing pagination cursors for entities returned from other loader methods that can then be passed to loadPageAsync for pagination. Most commonly used for testing pagination behavior.
The entity to get the pagination cursor for.
The pagination cursor for the given entity.
Load an entity where uniqueFieldName equals fieldValue directly from the database, or null if no entity matches. See loadByIDFromDatabaseAsync for how this differs from the standard loader.
entity field being queried
uniqueFieldName field value being queried
row locking modifiers for the query
entity where uniqueFieldName equals fieldValue, or null if no entity matches the condition
Load an entity by ID directly from the database, bypassing the dataloader and cache.
Unlike EnforcingEntityLoader.loadByIDAsync, this
issues one database query per call and does not read from or write to the entity cache. It exists
for cases that need row locking modifiers, which are required to make this intent explicit.
skipLocked is not permitted here since a skipped row would be reported as not found.
Use loadByIDNullableFromDatabaseAsync with skipLocked.
ID of the entity
row locking modifiers for the query
entity matching ID
Load an entity by ID directly from the database, or return null if non-existent. See loadByIDFromDatabaseAsync for how this differs from the standard loader.
ID of the entity
row locking modifiers for the query
entity for matching ID, or null if no entity exists for ID
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 many entities where fieldName equals fieldValue directly from the database. See loadByIDFromDatabaseAsync for how this differs from the standard loader.
entity field being queried
fieldName field value being queried
row locking modifiers for the query
array of entities where fieldName equals fieldValue
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 EnforcingEntityLoader.loadManyByFieldEqualingAsync.
entities matching the filters
Load many entities for a list of IDs directly from the database. See loadByIDFromDatabaseAsync for how this differs from the standard loader.
skipLocked is not permitted here since a skipped row would be reported as not found.
Use loadManyByIDsNullableFromDatabaseAsync with skipLocked.
IDs of the entities to load
row locking modifiers for the query
map from ID to corresponding entity
Load many entities for a list of IDs directly from the database, returning null for any IDs that are non-existent. See loadByIDFromDatabaseAsync for how this differs from the standard loader.
IDs of the entities to load
row locking modifiers for the query
map from ID to nullable corresponding entity
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 } = SQLExpression;
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.