Docs: Schreib Docs
This commit is contained in:
@@ -14,41 +14,39 @@ class AccountRepository {
|
||||
}
|
||||
|
||||
/// Entfernt ein Konto aus der Datenbank
|
||||
Future<int> remove(final Account account) async {
|
||||
return (_db.delete(_db.accounts)
|
||||
..where((t) => t.id.equals(account.id))).go();
|
||||
}
|
||||
Future<int> remove(final Account account) => (_db.delete(
|
||||
_db.accounts,
|
||||
)..where((final t) => t.id.equals(account.id))).go();
|
||||
|
||||
/// Sucht ein Konto anhand seiner Id aus der Datenbank
|
||||
Future<Account?> find(final int id) async {
|
||||
return (_db.select(_db.accounts)
|
||||
..where((t) => t.id.equals(id))).getSingleOrNull();
|
||||
}
|
||||
Future<Account?> find(final int id) => (_db.select(
|
||||
_db.accounts,
|
||||
)..where((final t) => t.id.equals(id))).getSingleOrNull();
|
||||
|
||||
/// Sucht Konten anhand der gegebenen Parameter aus der Datenbank
|
||||
Future<List<Account>> findBy({
|
||||
final int? id,
|
||||
final String? name,
|
||||
final String? orderBy,
|
||||
}) async {
|
||||
final query = _db.select(_db.accounts);
|
||||
}) {
|
||||
final SimpleSelectStatement<$AccountsTable, Account> query = _db.select(
|
||||
_db.accounts,
|
||||
);
|
||||
|
||||
if (id != null) {
|
||||
query.where((t) => t.id.equals(id));
|
||||
query.where((final t) => t.id.equals(id));
|
||||
}
|
||||
|
||||
if (name != null && name.isNotEmpty) {
|
||||
query.where((t) => t.name.like('%$name%'));
|
||||
query.where((final t) => t.name.like('%$name%'));
|
||||
}
|
||||
|
||||
if (orderBy != null) {
|
||||
switch (orderBy) {
|
||||
case 'nameAsc':
|
||||
query.orderBy([(t) => OrderingTerm.asc(t.name)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.asc(t.name)]);
|
||||
case 'nameDesc':
|
||||
query.orderBy([(t) => OrderingTerm.desc(t.name)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.desc(t.name)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user