Created
December 10, 2021 04:41
-
-
Save manakuro/876d140358028c960279c9054493e4cb 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 ( | |
"context" | |
"golang-clean-architecture-ent-gqlgen/ent" | |
"golang-clean-architecture-ent-gqlgen/ent/user" | |
"golang-clean-architecture-ent-gqlgen/pkg/entity/model" | |
usecaseRepository "golang-clean-architecture-ent-gqlgen/pkg/usecase/repository" | |
) | |
type userRepository struct { | |
client *ent.Client | |
} | |
func NewUserRepository(client *ent.Client) usecaseRepository.User { | |
return &userRepository{client: client} | |
} | |
func (r *userRepository) Get(ctx context.Context, id *int) (*model.User, error) { | |
u, err := r.client.User.Query().Where(user.IDEQ(*id)).Only(ctx) | |
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