BaseRepository<E, K> class abstract

Base repository interface for entity operations.

E is the entity type, and K is the primary key type.

Datapod generates implementations of this interface for classes annotated with @Repository().

Method Naming DSL (Derived Queries)

You can define repository methods by following naming conventions that the generator will translate into SQL queries:

  • Prefixes: find, read, query, get.
  • Filters: use By followed by field names and optional operators.
  • Operators:
    • Containing: findByNameContaining(String part)
    • StartingWith: findByEmailStartingWith(String prefix)
    • EndingWith: findByEmailEndingWith(String suffix)
    • GreaterThan, LessThan: findByAgeGreaterThan(int age)
    • IsNull, IsNotNull: findByProfileIsNull()
  • Logical Operators: And, Or (e.g., findByNameAndAge).

Example:

@Repository()
abstract class UserRepository extends BaseRepository<User, int> {
  // Generated: SELECT * FROM user WHERE email = @email
  Future<User?> findByEmail(String email);

  // Generated: SELECT * FROM user WHERE age > @age AND active = true
  Future<List<User>> findByAgeGreaterThanAndActiveTrue(int age);
}

Constructors

BaseRepository(RelationshipContext relationshipContext)

Properties

hashCode int
The hash code for this object.
no setterinherited
relationshipContext RelationshipContext
The context used for relationship orchestration and database access.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete(K id) Future<void>
Deletes the entity with the given id from the database.
findAll({List<Sort>? sort}) Future<List<E>>
Finds all entities.
findAllPaged(Pageable pageable) Future<Page<E>>
Finds a page of entities.
findById(K id) Future<E?>
Finds an entity by its primary key id.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save(E entity) Future<E>
Saves the given entity to the database.
saveAll(List<E> entities) Future<List<E>>
Saves all given entities to the database in a batch or sequential order.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited