mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
8efc3854ab
refactor: language mappings implementation
25 lines
467 B
Go
25 lines
467 B
Go
package repositories
|
|
|
|
import (
|
|
"github.com/muety/wakapi/models"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type AliasRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewAliasRepository(db *gorm.DB) *AliasRepository {
|
|
return &AliasRepository{db: db}
|
|
}
|
|
|
|
func (r *AliasRepository) GetByUser(userId string) ([]*models.Alias, error) {
|
|
var aliases []*models.Alias
|
|
if err := r.db.
|
|
Where(&models.Alias{UserID: userId}).
|
|
Find(&aliases).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return aliases, nil
|
|
}
|