2025-07-07 11:01:09 +08:00
|
|
|
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';
|
|
|
|
|
|
|
|
|
|
class DriftStackRepository extends DriftDatabaseRepository {
|
|
|
|
|
final Drift _db;
|
|
|
|
|
const DriftStackRepository(this._db) : super(_db);
|
|
|
|
|
|
|
|
|
|
Future<List<Stack>> getAll(String userId) {
|
2025-07-25 08:07:22 +05:30
|
|
|
final query = _db.stackEntity.select()..where((e) => e.ownerId.equals(userId));
|
2025-07-07 11:01:09 +08:00
|
|
|
|
|
|
|
|
return query.map((stack) {
|
|
|
|
|
return stack.toDto();
|
|
|
|
|
}).get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension on StackEntityData {
|
|
|
|
|
Stack toDto() {
|
2025-07-29 00:34:03 +05:30
|
|
|
return Stack(id: id, createdAt: createdAt, updatedAt: updatedAt, ownerId: ownerId, primaryAssetId: primaryAssetId);
|
2025-07-07 11:01:09 +08:00
|
|
|
}
|
|
|
|
|
}
|