CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/golang-gorm-io--gorm

tessl install tessl/golang-gorm-io--gorm@1.31.0

Full-featured ORM library for Golang with associations, hooks, transactions, migrations, and developer-friendly chainable API

Agent Success

Agent success rate when using this tile

81%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.13x

Baseline

Agent success rate without this tile

72%

task.mdevals/scenario-2/

User Management System

Build a simple user management system that tracks users with automatic timestamp management.

Requirements

The system should manage user records with the following capabilities:

  1. User Model: Create a user data structure that includes:

    • A unique identifier
    • Username (string)
    • Email address (string)
    • Automatic creation timestamp
    • Automatic update timestamp
    • Soft delete support (deleted records should be marked, not removed)
  2. Database Operations: Implement the following operations:

    • Create a new user
    • Update an existing user's information
    • Soft delete a user (mark as deleted without actually removing)
    • Retrieve an active (non-deleted) user by ID
    • List all active users
  3. Timestamp Behavior:

    • When a user is created, the creation timestamp should be set automatically
    • When a user is updated, the update timestamp should be refreshed automatically
    • When a user is soft deleted, the deletion timestamp should be set automatically
    • Queries should automatically exclude soft-deleted users unless explicitly requested

Implementation

@generates

The implementation should include:

  • A User struct definition
  • A UserManager struct with methods for all required operations
  • Proper database connection initialization
  • All operations should work with any SQL database supported by the ORM

Tests

  • Creating a user automatically sets the creation and update timestamps @test
  • Updating a user automatically updates the update timestamp @test
  • Soft deleting a user sets the deletion timestamp @test
  • Querying users excludes soft-deleted users by default @test
  • All timestamp fields are populated correctly @test

API

package main

import (
	"gorm.io/gorm"
)

// User represents a user in the system
type User struct {
	// Struct fields will be defined in implementation
}

// UserManager handles user-related database operations
type UserManager struct {
	db *gorm.DB
}

// NewUserManager creates a new UserManager instance
func NewUserManager(db *gorm.DB) *UserManager

// CreateUser creates a new user in the database
func (m *UserManager) CreateUser(username, email string) (*User, error)

// UpdateUser updates an existing user's information
func (m *UserManager) UpdateUser(id uint, username, email string) (*User, error)

// DeleteUser soft deletes a user
func (m *UserManager) DeleteUser(id uint) error

// GetUser retrieves a user by ID (excludes soft-deleted users)
func (m *UserManager) GetUser(id uint) (*User, error)

// ListUsers returns all active (non-deleted) users
func (m *UserManager) ListUsers() ([]User, error)

Dependencies { .dependencies }

gorm { .dependency }

Provides ORM functionality with automatic timestamp management and soft delete support.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/gorm.io/gorm@v1.31.1
tile.json