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)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,24 +10,24 @@ class RecurringTransactionRepository {
|
||||
|
||||
/// Fügt eine neue wiederkehrende Transaktion zur Datenbank hinzu
|
||||
Future<RecurringTransaction?> add(
|
||||
final RecurringTransactionsCompanion recurringTransaction,
|
||||
final RecurringTransactionsCompanion recurringTransaction,
|
||||
) async {
|
||||
final int id = await _db.into(_db.recurringTransactions).insert(
|
||||
recurringTransaction);
|
||||
final int id = await _db
|
||||
.into(_db.recurringTransactions)
|
||||
.insert(recurringTransaction);
|
||||
return find(id);
|
||||
}
|
||||
|
||||
/// Entfernt eine wiederkehrende Transaktion aus der Datenbank
|
||||
Future<int> remove(final RecurringTransaction recurringTransaction) async {
|
||||
return (_db.delete(_db.recurringTransactions)
|
||||
..where((t) => t.id.equals(recurringTransaction.id))).go();
|
||||
}
|
||||
Future<int> remove(final RecurringTransaction recurringTransaction) =>
|
||||
(_db.delete(
|
||||
_db.recurringTransactions,
|
||||
)..where((final t) => t.id.equals(recurringTransaction.id))).go();
|
||||
|
||||
/// Sucht eine wiederkehrende Transaktion anhand seiner Id aus der Datenbank
|
||||
Future<RecurringTransaction?> find(final int id) async {
|
||||
return (_db.select(_db.recurringTransactions)
|
||||
..where((t) => t.id.equals(id))).getSingleOrNull();
|
||||
}
|
||||
Future<RecurringTransaction?> find(final int id) => (_db.select(
|
||||
_db.recurringTransactions,
|
||||
)..where((final t) => t.id.equals(id))).getSingleOrNull();
|
||||
|
||||
/// Sucht wiederkehrende Transaktionen anhand der gegebenen Parameter
|
||||
/// aus der Datenbank
|
||||
@@ -44,70 +44,69 @@ class RecurringTransactionRepository {
|
||||
final double? amountMin,
|
||||
final double? amountMax,
|
||||
final String? orderBy,
|
||||
}) async {
|
||||
final query = _db.select(_db.recurringTransactions);
|
||||
}) {
|
||||
final SimpleSelectStatement<
|
||||
$RecurringTransactionsTable,
|
||||
RecurringTransaction
|
||||
>
|
||||
query = _db.select(_db.recurringTransactions);
|
||||
|
||||
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 (startDate != null) {
|
||||
query.where((t) => t.startDate.equals(startDate));
|
||||
query.where((final t) => t.startDate.equals(startDate));
|
||||
}
|
||||
|
||||
if (startDateAfter != null) {
|
||||
query.where((t) => t.startDate.isBiggerThanValue(startDateAfter));
|
||||
query.where((final t) => t.startDate.isBiggerThanValue(startDateAfter));
|
||||
}
|
||||
|
||||
if (startDateBefore != null) {
|
||||
query.where((t) => t.startDate.isSmallerThanValue(startDateBefore));
|
||||
query.where((final t) => t.startDate.isSmallerThanValue(startDateBefore));
|
||||
}
|
||||
|
||||
if (startDateFrom != null && startDateTo != null) {
|
||||
query.where((t) =>
|
||||
t.startDate.isBetweenValues(startDateFrom, startDateTo));
|
||||
query.where(
|
||||
(final t) => t.startDate.isBetweenValues(startDateFrom, startDateTo),
|
||||
);
|
||||
}
|
||||
|
||||
if (timeFrame != null) {
|
||||
query.where((t) => t.timeFrame.equals(timeFrame.index));
|
||||
query.where((final t) => t.timeFrame.equals(timeFrame.index));
|
||||
}
|
||||
|
||||
if (amount != null) {
|
||||
query.where((t) => t.amount.equals(amount));
|
||||
query.where((final t) => t.amount.equals(amount));
|
||||
}
|
||||
|
||||
if (amountMin != null) {
|
||||
query.where((t) => t.amount.isBiggerThanValue(amountMin));
|
||||
query.where((final t) => t.amount.isBiggerThanValue(amountMin));
|
||||
}
|
||||
|
||||
if (amountMax != null) {
|
||||
query.where((t) => t.amount.isSmallerThanValue(amountMax));
|
||||
query.where((final t) => t.amount.isSmallerThanValue(amountMax));
|
||||
}
|
||||
|
||||
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)]);
|
||||
case 'amountAsc':
|
||||
query.orderBy([(t) => OrderingTerm.asc(t.amount)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.asc(t.amount)]);
|
||||
case 'amountDesc':
|
||||
query.orderBy([(t) => OrderingTerm.desc(t.amount)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.desc(t.amount)]);
|
||||
case 'startDateAsc':
|
||||
query.orderBy([(t) => OrderingTerm.asc(t.startDate)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.asc(t.startDate)]);
|
||||
case 'startDateDesc':
|
||||
query.orderBy([(t) => OrderingTerm.desc(t.startDate)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.desc(t.startDate)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,16 +14,14 @@ class TransactionRepository {
|
||||
}
|
||||
|
||||
/// Entfernt eine Transaktion aus der Datenbank
|
||||
Future<int> remove(final Transaction transaction) async {
|
||||
return (_db.delete(_db.transactions)
|
||||
..where((t) => t.id.equals(transaction.id))).go();
|
||||
}
|
||||
Future<int> remove(final Transaction transaction) => (_db.delete(
|
||||
_db.transactions,
|
||||
)..where((final t) => t.id.equals(transaction.id))).go();
|
||||
|
||||
/// Sucht eine Transaktion anhand seiner Id aus der Datenbank
|
||||
Future<Transaction?> find(final int id) async {
|
||||
return (_db.select(_db.transactions)
|
||||
..where((t) => t.id.equals(id))).getSingleOrNull();
|
||||
}
|
||||
Future<Transaction?> find(final int id) => (_db.select(
|
||||
_db.transactions,
|
||||
)..where((final t) => t.id.equals(id))).getSingleOrNull();
|
||||
|
||||
/// Sucht Transaktionen anhand der gegebenen Parameter aus der Datenbank
|
||||
Future<List<Transaction>> findBy({
|
||||
@@ -36,61 +34,56 @@ class TransactionRepository {
|
||||
final double? amountMin,
|
||||
final double? amountMax,
|
||||
final String? orderBy,
|
||||
}) async {
|
||||
final query = _db.select(_db.transactions);
|
||||
}) {
|
||||
final SimpleSelectStatement<$TransactionsTable, Transaction> query = _db
|
||||
.select(_db.transactions);
|
||||
|
||||
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 (date != null) {
|
||||
query.where((t) => t.date.equals(date));
|
||||
query.where((final t) => t.date.equals(date));
|
||||
}
|
||||
|
||||
if (dateBefore != null) {
|
||||
query.where((t) => t.date.isBiggerThanValue(dateBefore));
|
||||
query.where((final t) => t.date.isBiggerThanValue(dateBefore));
|
||||
}
|
||||
|
||||
if (dateAfter != null) {
|
||||
query.where((t) => t.date.isSmallerThanValue(dateAfter));
|
||||
query.where((final t) => t.date.isSmallerThanValue(dateAfter));
|
||||
}
|
||||
|
||||
if (amount != null) {
|
||||
query.where((t) => t.amount.equals(amount));
|
||||
query.where((final t) => t.amount.equals(amount));
|
||||
}
|
||||
|
||||
if (amountMin != null) {
|
||||
query.where((t) => t.amount.isBiggerThanValue(amountMin));
|
||||
query.where((final t) => t.amount.isBiggerThanValue(amountMin));
|
||||
}
|
||||
|
||||
if (amountMax != null) {
|
||||
query.where((t) => t.amount.isSmallerThanValue(amountMax));
|
||||
query.where((final t) => t.amount.isSmallerThanValue(amountMax));
|
||||
}
|
||||
|
||||
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)]);
|
||||
case 'dateAsc':
|
||||
query.orderBy([(t) => OrderingTerm.asc(t.date)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.asc(t.date)]);
|
||||
case 'dateDesc':
|
||||
query.orderBy([(t) => OrderingTerm.desc(t.date)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.desc(t.date)]);
|
||||
case 'amountAsc':
|
||||
query.orderBy([(t) => OrderingTerm.asc(t.amount)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.asc(t.amount)]);
|
||||
case 'amountDesc':
|
||||
query.orderBy([(t) => OrderingTerm.desc(t.amount)]);
|
||||
break;
|
||||
query.orderBy([(final t) => OrderingTerm.desc(t.amount)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user