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-5/

User Profile Manager

Build a user profile management system that models a one-to-one relationship between users and their profile information.

Requirements

You need to create two related data structures:

  1. User Model - represents a user with:

    • ID (auto-generated)
    • Username (string)
    • Email (string)
  2. Profile Model - represents profile information with:

    • ID (auto-generated)
    • Bio (string)
    • AvatarURL (string)
    • DateOfBirth (string)
    • Reference to the associated user

The relationship structure: each user has exactly one profile, and the profile belongs to that user.

Functionality

Initialize Database

Initialize an in-memory SQLite database and automatically migrate the models to create the necessary tables.

Create User with Profile

  • Create a user named "alice" with email "alice@example.com" @test
  • Create the user's profile with bio "Software Engineer", avatar "https://example.com/alice.jpg", and date of birth "1990-01-15" @test
  • Both user and profile should be saved to the database @test

Retrieve User with Profile

  • Query for a user by username @test
  • The query should automatically load the associated profile in a single operation @test
  • Verify all user and profile fields are correctly populated @test

Update Profile

  • Modify an existing profile's bio and avatar URL @test
  • Save the changes to the database @test
  • Verify updates persist when querying the user again @test

Dependencies { .dependencies }

gorm.io/gorm { .dependency }

Provides object-relational mapping for database operations.

gorm.io/driver/sqlite { .dependency }

SQLite database driver for GORM.

Deliverables

Implement the solution in main.go with all required data structures and database operations. Include tests in main_test.go that verify the test cases above.

Version

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