inmemory to postgres
This commit is contained in:
@@ -73,6 +73,34 @@ export class Team implements IEntity<string> {
|
||||
});
|
||||
}
|
||||
|
||||
static rehydrate(props: {
|
||||
id: string;
|
||||
name: string;
|
||||
tag: string;
|
||||
description: string;
|
||||
ownerId: string;
|
||||
leagues: string[];
|
||||
createdAt: Date;
|
||||
}): Team {
|
||||
if (!props.id || props.id.trim().length === 0) {
|
||||
throw new RacingDomainValidationError('Team ID is required');
|
||||
}
|
||||
|
||||
if (!Array.isArray(props.leagues)) {
|
||||
throw new RacingDomainValidationError('Team leagues must be an array');
|
||||
}
|
||||
|
||||
return new Team({
|
||||
id: props.id,
|
||||
name: TeamName.create(props.name),
|
||||
tag: TeamTag.create(props.tag),
|
||||
description: TeamDescription.create(props.description),
|
||||
ownerId: DriverId.create(props.ownerId),
|
||||
leagues: props.leagues.map(leagueId => LeagueId.create(leagueId)),
|
||||
createdAt: TeamCreatedAt.create(props.createdAt),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy with updated properties.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user