GetByID binds a single record from the databases to the "dest".
(ctx context.Context, dest interface{}, id int64)
| 39 | |
| 40 | // GetByID binds a single record from the databases to the "dest". |
| 41 | func (s *Service) GetByID(ctx context.Context, dest interface{}, id int64) error { |
| 42 | q := fmt.Sprintf("SELECT * FROM %s WHERE %s = ? LIMIT 1", s.rec.TableName(), s.rec.PrimaryKey()) |
| 43 | err := s.db.Get(ctx, dest, q, id) |
| 44 | return err |
| 45 | // if err != nil { |
| 46 | // if err == sql.ErrNoRows { |
| 47 | // return false, nil |
| 48 | // } |
| 49 | |
| 50 | // return false, err |
| 51 | // } |
| 52 | |
| 53 | // return true, nil |
| 54 | } |
| 55 | |
| 56 | // Count returns the total records count in the table. |
| 57 | func (s *Service) Count(ctx context.Context) (total int64, err error) { |
nothing calls this directly
no test coverage detected