Files
go-eve-pi/repositories/base.go

33 lines
793 B
Go

// Package repositories provides database repository implementations
// with a clean separation of concerns and proper interface abstractions.
package repositories
import (
"gorm.io/gorm"
)
// BaseRepository provides common database operations
type BaseRepository struct {
db *gorm.DB
}
// NewBaseRepository creates a new base repository
func NewBaseRepository(db *gorm.DB) *BaseRepository {
return &BaseRepository{db: db}
}
// DB returns the underlying gorm.DB instance
func (r *BaseRepository) DB() *gorm.DB {
return r.db
}
// Raw executes raw SQL
func (r *BaseRepository) Raw(sql string, args ...any) *gorm.DB {
return r.db.Raw(sql, args...)
}
// AutoMigrate runs auto migration
func (r *BaseRepository) AutoMigrate(dst ...interface{}) error {
return r.db.AutoMigrate(dst...)
}