github.com/oinume/lekcije@v0.0.0-20231017100347-5b4c5eb6ab24/backend/infrastructure/mysql/lesson_status_log.go (about) 1 package mysql 2 3 import ( 4 "context" 5 "database/sql" 6 7 "github.com/morikuni/failure" 8 "github.com/volatiletech/sqlboiler/v4/boil" 9 10 "github.com/oinume/lekcije/backend/domain/repository" 11 "github.com/oinume/lekcije/backend/errors" 12 "github.com/oinume/lekcije/backend/model2" 13 ) 14 15 type lessonStatusLogRepo struct { 16 db *sql.DB 17 } 18 19 func NewLessonStatusLogRepository(db *sql.DB) repository.LessonStatusLog { 20 return &lessonStatusLogRepo{db: db} 21 } 22 23 func (r *lessonStatusLogRepo) Create(ctx context.Context, log *model2.LessonStatusLog) error { 24 if err := log.Insert(ctx, r.db, boil.Infer()); err != nil { 25 return failure.Translate(err, errors.Internal) 26 } 27 return nil 28 }