GetByID returns the user with given ID. It returns ErrUserNotExist when not found.
(ctx context.Context, id int64)
| 730 | // GetByID returns the user with given ID. It returns ErrUserNotExist when not |
| 731 | // found. |
| 732 | func (s *UsersStore) GetByID(ctx context.Context, id int64) (*User, error) { |
| 733 | user := new(User) |
| 734 | err := s.db.WithContext(ctx).Where("id = ?", id).First(user).Error |
| 735 | if err != nil { |
| 736 | if errors.Is(err, gorm.ErrRecordNotFound) { |
| 737 | return nil, ErrUserNotExist{args: errutil.Args{"userID": id}} |
| 738 | } |
| 739 | return nil, err |
| 740 | } |
| 741 | return user, nil |
| 742 | } |
| 743 | |
| 744 | // GetByUsername returns the user with given username. It returns |
| 745 | // ErrUserNotExist when not found. |
no test coverage detected