wip, immutable types
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,8 @@
|
||||
import 'model.dart' as _i1;
|
||||
import 'prisma.dart' as _i2;
|
||||
|
||||
class Task {
|
||||
const Task({
|
||||
class TaskDbo {
|
||||
const TaskDbo({
|
||||
this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
@@ -13,7 +13,7 @@ class Task {
|
||||
this.project,
|
||||
});
|
||||
|
||||
factory Task.fromJson(Map json) => Task(
|
||||
factory TaskDbo.fromJson(Map json) => TaskDbo(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
@@ -29,7 +29,7 @@ class Task {
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
project: json['project'] is Map
|
||||
? _i1.Project.fromJson(json['project'])
|
||||
? _i1.ProjectDbo.fromJson(json['project'])
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -45,7 +45,7 @@ class Task {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final _i1.Project? project;
|
||||
final _i1.ProjectDbo? project;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@@ -58,8 +58,8 @@ class Task {
|
||||
};
|
||||
}
|
||||
|
||||
class TimeEntry {
|
||||
const TimeEntry({
|
||||
class TimeEntryDbo {
|
||||
const TimeEntryDbo({
|
||||
this.id,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
@@ -72,7 +72,7 @@ class TimeEntry {
|
||||
this.project,
|
||||
});
|
||||
|
||||
factory TimeEntry.fromJson(Map json) => TimeEntry(
|
||||
factory TimeEntryDbo.fromJson(Map json) => TimeEntryDbo(
|
||||
id: json['id'],
|
||||
startTime: switch (json['startTime']) {
|
||||
DateTime value => value,
|
||||
@@ -97,9 +97,9 @@ class TimeEntry {
|
||||
String value => DateTime.parse(value),
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
|
||||
user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
|
||||
project: json['project'] is Map
|
||||
? _i1.Project.fromJson(json['project'])
|
||||
? _i1.ProjectDbo.fromJson(json['project'])
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -119,9 +119,9 @@ class TimeEntry {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final _i1.User? user;
|
||||
final _i1.UserDbo? user;
|
||||
|
||||
final _i1.Project? project;
|
||||
final _i1.ProjectDbo? project;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@@ -137,8 +137,8 @@ class TimeEntry {
|
||||
};
|
||||
}
|
||||
|
||||
class Project {
|
||||
const Project({
|
||||
class ProjectDbo {
|
||||
const ProjectDbo({
|
||||
this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
@@ -152,7 +152,7 @@ class Project {
|
||||
this.$count,
|
||||
});
|
||||
|
||||
factory Project.fromJson(Map json) => Project(
|
||||
factory ProjectDbo.fromJson(Map json) => ProjectDbo(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
@@ -169,12 +169,12 @@ class Project {
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
tasks: (json['tasks'] as Iterable?)
|
||||
?.map((json) => _i1.Task.fromJson(json)),
|
||||
?.map((json) => _i1.TaskDbo.fromJson(json)),
|
||||
timeEntries: (json['timeEntries'] as Iterable?)
|
||||
?.map((json) => _i1.TimeEntry.fromJson(json)),
|
||||
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
|
||||
?.map((json) => _i1.TimeEntryDbo.fromJson(json)),
|
||||
user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
|
||||
$count: json['_count'] is Map
|
||||
? _i2.ProjectCountOutputType.fromJson(json['_count'])
|
||||
? _i2.ProjectDboCountOutputType.fromJson(json['_count'])
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -192,13 +192,13 @@ class Project {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final Iterable<_i1.Task>? tasks;
|
||||
final Iterable<_i1.TaskDbo>? tasks;
|
||||
|
||||
final Iterable<_i1.TimeEntry>? timeEntries;
|
||||
final Iterable<_i1.TimeEntryDbo>? timeEntries;
|
||||
|
||||
final _i1.User? user;
|
||||
final _i1.UserDbo? user;
|
||||
|
||||
final _i2.ProjectCountOutputType? $count;
|
||||
final _i2.ProjectDboCountOutputType? $count;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@@ -215,8 +215,8 @@ class Project {
|
||||
};
|
||||
}
|
||||
|
||||
class User {
|
||||
const User({
|
||||
class UserDbo {
|
||||
const UserDbo({
|
||||
this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
@@ -228,7 +228,7 @@ class User {
|
||||
this.$count,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map json) => User(
|
||||
factory UserDbo.fromJson(Map json) => UserDbo(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
email: json['email'],
|
||||
@@ -244,11 +244,11 @@ class User {
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
projects: (json['projects'] as Iterable?)
|
||||
?.map((json) => _i1.Project.fromJson(json)),
|
||||
?.map((json) => _i1.ProjectDbo.fromJson(json)),
|
||||
timeEntries: (json['timeEntries'] as Iterable?)
|
||||
?.map((json) => _i1.TimeEntry.fromJson(json)),
|
||||
?.map((json) => _i1.TimeEntryDbo.fromJson(json)),
|
||||
$count: json['_count'] is Map
|
||||
? _i2.UserCountOutputType.fromJson(json['_count'])
|
||||
? _i2.UserDboCountOutputType.fromJson(json['_count'])
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -264,11 +264,11 @@ class User {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final Iterable<_i1.Project>? projects;
|
||||
final Iterable<_i1.ProjectDbo>? projects;
|
||||
|
||||
final Iterable<_i1.TimeEntry>? timeEntries;
|
||||
final Iterable<_i1.TimeEntryDbo>? timeEntries;
|
||||
|
||||
final _i2.UserCountOutputType? $count;
|
||||
final _i2.UserDboCountOutputType? $count;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@@ -283,8 +283,8 @@ class User {
|
||||
};
|
||||
}
|
||||
|
||||
class CreateManyUserAndReturnOutputType {
|
||||
const CreateManyUserAndReturnOutputType({
|
||||
class CreateManyUserDboAndReturnOutputType {
|
||||
const CreateManyUserDboAndReturnOutputType({
|
||||
this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
@@ -293,8 +293,8 @@ class CreateManyUserAndReturnOutputType {
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory CreateManyUserAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyUserAndReturnOutputType(
|
||||
factory CreateManyUserDboAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyUserDboAndReturnOutputType(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
email: json['email'],
|
||||
@@ -333,8 +333,8 @@ class CreateManyUserAndReturnOutputType {
|
||||
};
|
||||
}
|
||||
|
||||
class CreateManyProjectAndReturnOutputType {
|
||||
const CreateManyProjectAndReturnOutputType({
|
||||
class CreateManyProjectDboAndReturnOutputType {
|
||||
const CreateManyProjectDboAndReturnOutputType({
|
||||
this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
@@ -345,8 +345,8 @@ class CreateManyProjectAndReturnOutputType {
|
||||
this.user,
|
||||
});
|
||||
|
||||
factory CreateManyProjectAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyProjectAndReturnOutputType(
|
||||
factory CreateManyProjectDboAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyProjectDboAndReturnOutputType(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
@@ -362,7 +362,7 @@ class CreateManyProjectAndReturnOutputType {
|
||||
String value => DateTime.parse(value),
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
|
||||
user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
|
||||
);
|
||||
|
||||
final String? id;
|
||||
@@ -379,7 +379,7 @@ class CreateManyProjectAndReturnOutputType {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final _i1.User? user;
|
||||
final _i1.UserDbo? user;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@@ -393,8 +393,8 @@ class CreateManyProjectAndReturnOutputType {
|
||||
};
|
||||
}
|
||||
|
||||
class CreateManyTimeEntryAndReturnOutputType {
|
||||
const CreateManyTimeEntryAndReturnOutputType({
|
||||
class CreateManyTimeEntryDboAndReturnOutputType {
|
||||
const CreateManyTimeEntryDboAndReturnOutputType({
|
||||
this.id,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
@@ -407,8 +407,8 @@ class CreateManyTimeEntryAndReturnOutputType {
|
||||
this.project,
|
||||
});
|
||||
|
||||
factory CreateManyTimeEntryAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyTimeEntryAndReturnOutputType(
|
||||
factory CreateManyTimeEntryDboAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyTimeEntryDboAndReturnOutputType(
|
||||
id: json['id'],
|
||||
startTime: switch (json['startTime']) {
|
||||
DateTime value => value,
|
||||
@@ -433,9 +433,9 @@ class CreateManyTimeEntryAndReturnOutputType {
|
||||
String value => DateTime.parse(value),
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
user: json['user'] is Map ? _i1.User.fromJson(json['user']) : null,
|
||||
user: json['user'] is Map ? _i1.UserDbo.fromJson(json['user']) : null,
|
||||
project: json['project'] is Map
|
||||
? _i1.Project.fromJson(json['project'])
|
||||
? _i1.ProjectDbo.fromJson(json['project'])
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -455,9 +455,9 @@ class CreateManyTimeEntryAndReturnOutputType {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final _i1.User? user;
|
||||
final _i1.UserDbo? user;
|
||||
|
||||
final _i1.Project? project;
|
||||
final _i1.ProjectDbo? project;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@@ -473,8 +473,8 @@ class CreateManyTimeEntryAndReturnOutputType {
|
||||
};
|
||||
}
|
||||
|
||||
class CreateManyTaskAndReturnOutputType {
|
||||
const CreateManyTaskAndReturnOutputType({
|
||||
class CreateManyTaskDboAndReturnOutputType {
|
||||
const CreateManyTaskDboAndReturnOutputType({
|
||||
this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
@@ -484,8 +484,8 @@ class CreateManyTaskAndReturnOutputType {
|
||||
this.project,
|
||||
});
|
||||
|
||||
factory CreateManyTaskAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyTaskAndReturnOutputType(
|
||||
factory CreateManyTaskDboAndReturnOutputType.fromJson(Map json) =>
|
||||
CreateManyTaskDboAndReturnOutputType(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
@@ -501,7 +501,7 @@ class CreateManyTaskAndReturnOutputType {
|
||||
_ => json['updatedAt']
|
||||
},
|
||||
project: json['project'] is Map
|
||||
? _i1.Project.fromJson(json['project'])
|
||||
? _i1.ProjectDbo.fromJson(json['project'])
|
||||
: null,
|
||||
);
|
||||
|
||||
@@ -517,7 +517,7 @@ class CreateManyTaskAndReturnOutputType {
|
||||
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final _i1.Project? project;
|
||||
final _i1.ProjectDbo? project;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,8 +14,8 @@ class PrismaUserRepository implements UserRepository {
|
||||
if (user.password == null) {
|
||||
throw Exception('Password is required');
|
||||
}
|
||||
prisma.user.create(
|
||||
data: PrismaUnion.$1(UserCreateInput(
|
||||
prisma.userDbo.create(
|
||||
data: PrismaUnion.$1(UserDboCreateInput(
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
@@ -25,8 +25,8 @@ class PrismaUserRepository implements UserRepository {
|
||||
|
||||
@override
|
||||
Future<User?> findByEmail(String email) async {
|
||||
final user =
|
||||
await prisma.user.findUnique(where: UserWhereUniqueInput(email: email));
|
||||
final user = await prisma.userDbo
|
||||
.findUnique(where: UserDboWhereUniqueInput(email: email));
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class PrismaUserRepository implements UserRepository {
|
||||
@override
|
||||
Future<User?> findById(String id) async {
|
||||
final user =
|
||||
await prisma.user.findUnique(where: UserWhereUniqueInput(id: id));
|
||||
await prisma.userDbo.findUnique(where: UserDboWhereUniqueInput(id: id));
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user