Skip to content

Commit

Permalink
drop: on DatabaseRepository
Browse files Browse the repository at this point in the history
wip drop: `RepositoryV2`

wip #377
  • Loading branch information
zin- committed Aug 28, 2024
1 parent fd828de commit e17dd71
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
18 changes: 12 additions & 6 deletions lib/framework/database/definition/database_definition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:mem/framework/database/definition/exceptions.dart';
import 'package:mem/framework/database/definition/table_definition.dart';
import 'package:mem/framework/repository/entity.dart';

class DatabaseDefinition extends EntityV2 {
class DatabaseDefinition with Entity {
final String name;
final int version;
final List<TableDefinition> tableDefinitions;
Expand All @@ -21,10 +21,16 @@ class DatabaseDefinition extends EntityV2 {
}
}

// coverage:ignore-start
@override
String toString() => "${super.toString()}: ${{
"name": name,
"version": version,
"tableDefinitions": tableDefinitions.map((e) => e.toString())
}}";
Entity copiedWith() => throw UnimplementedError();

// coverage:ignore-end

@override
Map<String, dynamic> get toMap => {
'name': name,
'version': version,
'tableDefinitions': tableDefinitions.map((e) => e.toString())
};
}
4 changes: 1 addition & 3 deletions lib/framework/repository/database_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import 'package:mem/framework/database/factory.dart';
import 'package:mem/framework/repository/repository.dart';
import 'package:mem/logger/log_service.dart';

class DatabaseRepository extends RepositoryV2<DatabaseDefinition>
with Receiver<DatabaseDefinition, DatabaseAccessor> {
class DatabaseRepository extends Repository<DatabaseDefinition> {
static DatabaseRepository? _instance;

final _cache = <String, DatabaseAccessor>{};
Expand All @@ -18,7 +17,6 @@ class DatabaseRepository extends RepositoryV2<DatabaseDefinition>

factory DatabaseRepository() => _instance ??= DatabaseRepository._();

@override
Future<DatabaseAccessor> receive(DatabaseDefinition entity) => v(
() async =>
_cache[entity.name] ??
Expand Down
1 change: 1 addition & 0 deletions lib/framework/repository/entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ abstract class EntityV1 {}
mixin Entity {
Map<String, dynamic> get toMap;

// FIXME EntityではなくCopyableみたいなmixinで切り出すべきかもしれない
Entity copiedWith();

@override
Expand Down

0 comments on commit e17dd71

Please sign in to comment.