func (maker *studentMaker) GetByID(id int64) (*Student, error) { var ( student *Student = &Student{} query string = queries["get_student"] err error = util.GetAndMarshal(query, maker, student, id) ) if err != nil { return nil, err } return student, nil }
func (maker *userMaker) GetByID(id int64) (*User, error) { var ( user *User = &User{} query string = fmt.Sprintf(queries["get_user"], user.GetColumns()) err error = util.GetAndMarshal(query, maker, user, id) ) if err != nil { return nil, err } return user, nil }
func (maker *teacherMaker) GetByID(id int64) (*Teacher, error) { query, _, err := sq. Select("teacher.id", "t_user.first_name", "t_user.last_name", "t_user.username", "t_user.created_at", "t_user.last_updated"). From("teacher"). Join("t_user on teacher.user_id=t_user.id"). Where(sq.Eq{"teacher.id": id}). ToSql() if err != nil { return nil, err } var teacher = &Teacher{} err = util.GetAndMarshal(query, maker, teacher, id) if err != nil { return nil, err } return teacher, nil }