MCPcopy Create free account
hub / github.com/kataras/iris / GetByID

Method GetByID

_examples/database/mysql/sql/service.go:41–54  ·  view source on GitHub ↗

GetByID binds a single record from the databases to the "dest".

(ctx context.Context, dest interface{}, id int64)

Source from the content-addressed store, hash-verified

39
40// GetByID binds a single record from the databases to the "dest".
41func (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.
57func (s *Service) Count(ctx context.Context) (total int64, err error) {

Callers

nothing calls this directly

Calls 3

TableNameMethod · 0.65
PrimaryKeyMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected