Hallucinate a whole lot of shit...
Too much shit...
This commit is contained in:
30
repositories/base.go
Normal file
30
repositories/base.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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...)
|
||||
}
|
||||
Reference in New Issue
Block a user