37 lines
698 B
Go
37 lines
698 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
"rockhu-bot/local/model"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ConcertRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewConcertRepository(db *gorm.DB) *ConcertRepository {
|
|
return &ConcertRepository{
|
|
db: db,
|
|
}
|
|
}
|
|
|
|
// GetAll
|
|
// Gets all rows from Concert table.
|
|
//
|
|
// Args:
|
|
// context.Context: Application context
|
|
// Returns:
|
|
// model.ConcertModel: Concert object from database.
|
|
func (as ConcertRepository) GetAll(ctx context.Context) *[]model.ConcertModel {
|
|
db := as.db.WithContext(ctx)
|
|
ConcertModel := new([]model.ConcertModel)
|
|
db.Find(&ConcertModel)
|
|
return ConcertModel
|
|
}
|
|
|
|
func (as ConcertRepository) CreateTransaction() *gorm.DB {
|
|
return as.db.Begin()
|
|
}
|