serverctl/services/entry/pkg/db/postgres/userrepo.go
2022-02-17 21:39:56 +01:00

29 lines
474 B
Go

package postgres
import (
"context"
"errors"
)
type UserDto struct {
}
type InMemoryUserRepository struct {
users map[int]*UserDto
}
func NewInMemoryUserRepository() *InMemoryUserRepository {
return &InMemoryUserRepository{
users: make(map[int]*UserDto),
}
}
func (ur *InMemoryUserRepository) Get(ctx context.Context, id int) (*UserDto, error) {
user := ur.users[id]
if user == nil {
return nil, errors.New("user is not in database")
}
return user, nil
}