Last active
February 10, 2023 08:41
-
-
Save manakuro/259c0666cb6d15663584c315c29d929c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package repository | |
import ( | |
"golang-clean-architecture/domain/model" | |
"golang-clean-architecture/usecase/repository" | |
"github.com/jinzhu/gorm" | |
) | |
type userRepository struct { | |
db *gorm.DB | |
} | |
func NewUserRepository(db *gorm.DB) repository.UserRepository { | |
return &userRepository{db} | |
} | |
func (ur *userRepository) FindAll(u []*model.User) ([]*model.User, error) { | |
err := ur.db.Find(&u).Error | |
if err != nil { | |
return nil, err | |
} | |
return u, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment