DatabaseRepository<T extends DatabaseStorable> class

A repository for databases exposing utility functions to easily persist objects to a database in a database independent way

Inheritance
Mixed in types

Constructors

DatabaseRepository({required SerializerInterface<T> serializer, DatabaseAdapter? adapter})
Constructs a DatabaseRepository with the given serializer. If no adapter was provided it will lookup the default adapter from the registry Thows a NoSuchAdapterException if neither an adapter was provided not a default adapter was registered;
DatabaseRepository.fromRegistry({required SerializerInterface<T> serializer, required String name})
Constructs a DatabaseRepository with the given serializer. Looksup the named adapter from the registry Thows a NoSuchAdapterException if neither an adapter was provided not a default adapter was registered;

Properties

adapter DatabaseAdapter
The DatabaseAdapter that is used to persist the objects
latefinal
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializer SerializerInterface<T>
The serializer that the repository can use to convert between an object and JSON
final

Methods

create(T element) Future<T>
Gets and executes a create Query for element
delete(T element) Future<void>
Gets and executes a delete Query for element
executeQuery(Query query) Future<QueryResult>
Execute a query upon the adapter
override
getCreateQuery(T element) Query
generates a query that execute a create operation on the database
inherited
getDeleteQuery(T element) Query
generates a query that execute a delete operation on the database
inherited
getReadAllQuery({required String entityName}) Query
generates a query that execute a read operation on the database fetching all objects
inherited
getReadAllWhereQuery({required String entityName, List<Constraint> where = const [], int? limit}) Query
generates a query that execute a read operation on the database by applying a search function
inherited
getReadQuery(String id, {Type? type, required String entityName}) Query
generates a query that execute a read operation on the database for an object with a given id.
inherited
getStoreQuery(T element, {bool updateIfExists = false}) Query
generates a create or update query depending if the object should be updated if it exists
inherited
getUpdateQuery(T element) Query
generates a query that execute a update operation on the database
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String id) Future<T>
Gets and executes a read Query to fetch an entity of Type T with the given id
readAll() Future<List<T>>
Gets and executes a read Query to fetch an entity of Type T with the given id
readAllWhere({List<Constraint> where = const [], int? limit}) Future<List<T>>
Gets and executes a read Query to fetch an entity of Type T with the given id
store(T element) Future<T>
Gets and executes a store Query for element
toString() String
A string representation of this object.
inherited
update(T element) Future<T>
Gets and executes a update Query for element

Operators

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