Olaoluwa Oke| 28 February 2024
This afternoon, I sat at my desk wondering why my TaskRequest
DTO wasn’t being recognized. Turned out I had actually named it
TaskCreateRequest in the code. Minor mistake,
but it killed my flow and even made me pause my music.
Most of today went into building the Task entity. Sticking to
the Interface Metaphor idea, I almost named it Chores — more homely
— but ironically, I type “chores” slower than “task.” So “task” it is.
@Document(collection = "tasks")
data class Task(
@Id val id: String? = null,
val name: String,
val description: String?,
val dueDate: Instant?,
val assignedTo: String?, // userId, nullable
val roomId: String,
val status: TaskStatus = TaskStatus.PENDING,
val recurrence: Recurrence? = null,
val createdAt: Instant = Instant.now()
)
enum class TaskStatus { PENDING, IN_PROGRESS, COMPLETED }
enum class Recurrence { DAILY, WEEKLY, MONTHLY, NONE }
interface TaskRepository : MongoRepository<.Task, String> {
fun findByRoomId(roomId: String): List<.Task>
fun findByRoomIdAndName(roomId: String, name: String): List<.Task>
}