repo<T extends OrmEntity> method
Returns a repository for performing CRUD operations on the specified model type.
CRUD helpers for a single model type.
Reads delegate to the Query builder. Writes build MutationPlan objects that are executed by the active driver.
Obtain a repository from DataSource.repo<T>(),
QueryContext.repository<T>(), or Model.repository<T>().
final repo = dataSource.repo<$User>();
final inserted = await repo.insert(
$UserInsertDto(email: 'john@example.com'),
);
final updated = await repo.update(
$UserUpdateDto(name: 'John'),
where: {'id': inserted.id},
);
final exists = await repo.exists(where: {'email': 'john@example.com'});
final userRepo = ds.repo<User>();
await userRepo.insert(newUser);
await userRepo.updateMany([updatedUser]);
await userRepo.deleteByKeys([{'id': userId}]);
Implementation
Repository<T> repo<T extends OrmEntity>() {
_ensureInitialized();
return _connection!.repository<T>();
}