Menyelesaikan object user dan init base
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { User } from '../../domain/entities/user.entity';
|
||||
|
||||
export class PrismaUserMapper {
|
||||
static toDomain(model: any): User | null {
|
||||
if (!model) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return User.restore({
|
||||
id: model.id,
|
||||
name: model.name,
|
||||
email: model.email,
|
||||
password: model.password,
|
||||
metadata: model.metadata,
|
||||
});
|
||||
}
|
||||
|
||||
static toPersistence(user: User) {
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
password: user.password,
|
||||
metadata: user.metadata ?? {},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user