Full-featured ORM library for Golang with associations, hooks, transactions, migrations, and developer-friendly chainable API
Overall
score
81%
Build a task management system that supports both archiving (soft delete) and permanent deletion (hard delete) of tasks.
Implement a task management system with the following features:
Task Model: Create a Task model with fields for ID, title, description, completed status, and timestamps (including soft delete support).
Archive Task: Implement a function ArchiveTask(db, taskID) that archives (soft deletes) a task by its ID. Archived tasks should not appear in normal queries.
Permanently Delete Task: Implement a function PermanentlyDeleteTask(db, taskID) that permanently removes a task from the database, bypassing any soft delete mechanism.
List Active Tasks: Implement a function ListActiveTasks(db) that returns all non-archived tasks.
List Archived Tasks: Implement a function ListArchivedTasks(db) that returns only the archived tasks.
Bulk Archive Completed Tasks: Implement a function BulkArchiveCompletedTasks(db) that archives all tasks marked as completed.
task.go: Define the Task modeloperations.go: Implement all required functionsoperations_test.go: Test file with test casesProvides ORM functionality for database operations.
Provides SQLite database driver for GORM.
// File: operations_test.go
// Setup: Create 3 tasks
// Action: Archive task with ID 2
// Verify: ListActiveTasks returns 2 tasks (IDs 1 and 3)
// Verify: ListArchivedTasks returns 1 task (ID 2)// File: operations_test.go
// Setup: Create 2 tasks and archive task with ID 1
// Action: Call PermanentlyDeleteTask on task with ID 1
// Verify: ListArchivedTasks returns 0 tasks
// Verify: Database has only 1 task remaining (ID 2)// File: operations_test.go
// Setup: Create 5 tasks, mark 3 as completed
// Action: Call BulkArchiveCompletedTasks
// Verify: ListActiveTasks returns 2 tasks (uncompleted ones)
// Verify: ListArchivedTasks returns 3 tasks (completed ones)Install with Tessl CLI
npx tessl i tessl/golang-gorm-io--gormdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10