mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
* chore(mobile): use Drift @DriftAccessor() and collapse some providers * Fix import order * Required formatting
26 lines
914 B
Dart
26 lines
914 B
Dart
import 'package:drift/drift.dart';
|
|
import 'package:immich_mobile/domain/models/stack.model.dart';
|
|
import 'package:immich_mobile/infrastructure/entities/stack.entity.drift.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
|
import 'package:immich_mobile/infrastructure/repositories/stack.repository.drift.dart';
|
|
|
|
@DriftAccessor()
|
|
class StackRepository extends DatabaseAccessor<Drift> with $StackRepositoryMixin {
|
|
StackRepository(super.attachedDatabase);
|
|
|
|
Drift get _db => attachedDatabase;
|
|
|
|
Future<List<Stack>> getAll(String userId) {
|
|
final query = _db.stackEntity.select()..where((e) => e.ownerId.equals(userId));
|
|
|
|
return query.map((stack) {
|
|
return stack.toDto();
|
|
}).get();
|
|
}
|
|
}
|
|
|
|
extension on StackEntityData {
|
|
Stack toDto() {
|
|
return Stack(id: id, createdAt: createdAt, updatedAt: updatedAt, ownerId: ownerId, primaryAssetId: primaryAssetId);
|
|
}
|
|
}
|