struct { UUID string // uuid UserID string // user_id Name string // name Duration int64 // duration StartedAt time.Time // started_at IsCompleted bool // is_completed } // Create inserts the Todo to the database. func (r *Todo) Create(db Queryer) error { err := db.QueryRow( `INSERT INTO todo (user_id, name, duration, started_at, is_completed) VALUES ($1, $2, $3, $ 4, $5) RETURNING uuid`, &r.UserID, &r.Name, &r.Duration, &r.StartedAt, &r.IsCompleted).Scan(&r.UUID) if err != nil { return errors.Wrap(err, "failed to insert todo") } return nil } // GetTodoByPk select the Todo from the database. func GetTodoByPk(db Queryer, pk0 string) (*Todo, error) { var r Todo err := db.QueryRow( `SELECT uuid, user_id, name, duration, started_at, is_completed FROM todo WHERE uuid = $1`, pk0).Scan(&r.UUID, &r.UserID, &r.Name, &r.Duration, &r.StartedAt, &r.IsCompleted) if err != nil { return nil, errors.Wrap(err, "failed to select todo") } return &r, nil } IUUQTHJUIVCDPNBDIJLVHPUPEPJUCMPCNBTUFSNPEFMUBCMFHP