-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
backend/prisma/migrations/20230827071653_create_tasks/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- CreateTable | ||
CREATE TABLE "tasks" ( | ||
"id" VARCHAR(255) NOT NULL, | ||
"name" VARCHAR(255) NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "tasks_pkey" PRIMARY KEY ("id") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
export class TaskId { | ||
private constructor(private readonly id: string) { | ||
this.id = id; | ||
} | ||
|
||
static build(): TaskId { | ||
return new TaskId(uuidv4()); | ||
} | ||
|
||
static rebuild(value: string): TaskId { | ||
return new TaskId(value); | ||
} | ||
|
||
get value(): string { | ||
return this.id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export class TaskName { | ||
private constructor(private name: string) {} | ||
|
||
static build(name: string): TaskName { | ||
return new TaskName(name); | ||
} | ||
|
||
static rebuild(name: string): TaskName { | ||
return new TaskName(name); | ||
} | ||
|
||
get value(): string { | ||
return this.name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { TaskId } from './task-id'; | ||
import { TaskName } from './task-name'; | ||
|
||
interface TeamProps { | ||
id: TaskId; | ||
name: TaskName; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
} | ||
|
||
type TaskBuildProps = Omit<TeamProps, 'createdAt' | 'updatedAt'>; | ||
|
||
export class Task { | ||
private constructor(private props: TeamProps) {} | ||
|
||
static build(props: TaskBuildProps): Task { | ||
return new Task({ | ||
...props, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}); | ||
} | ||
|
||
static rebuild(props: TeamProps): Task { | ||
return new Task({ | ||
...props, | ||
}); | ||
} | ||
|
||
getAllProperties() { | ||
return { | ||
id: this.props.id.value, | ||
name: this.props.name.value, | ||
}; | ||
} | ||
} |