MCPcopy
hub / github.com/benbjohnson/wtf / FindUserByID

Method FindUserByID

sqlite/user.go:30–45  ·  view source on GitHub ↗

FindUserByID retrieves a user by ID along with their associated auth objects. Returns ENOTFOUND if user does not exist.

(ctx context.Context, id int)

Source from the content-addressed store, hash-verified

28// FindUserByID retrieves a user by ID along with their associated auth objects.
29// Returns ENOTFOUND if user does not exist.
30func (s *UserService) FindUserByID(ctx context.Context, id int) (*wtf.User, error) {
31 tx, err := s.db.BeginTx(ctx, nil)
32 if err != nil {
33 return nil, err
34 }
35 defer tx.Rollback()
36
37 // Fetch user and their associated OAuth objects.
38 user, err := findUserByID(ctx, tx, id)
39 if err != nil {
40 return nil, err
41 } else if err := attachUserAuths(ctx, tx, user); err != nil {
42 return user, err
43 }
44 return user, nil
45}
46
47// FindUsers retrieves a list of users by filter. Also returns total count of
48// matching users which may differ from returned results if filter.Limit is specified.

Callers 4

TestUserService_FindUserFunction · 0.95

Implementers 2

UserServicemock/user.go
UserServicesqlite/user.go

Calls 3

findUserByIDFunction · 0.85
attachUserAuthsFunction · 0.85
BeginTxMethod · 0.80

Tested by 4

TestUserService_FindUserFunction · 0.76