You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Class represents public.classtypeClassstruct {
IDint// idAge sql.NullInt64// ageName sql.NullString// nameSal sql.NullFloat64// sal
}
// Create inserts the Class to the database.func (r*Class) Create(dbQueryer) error {
err:=db.QueryRow(
`INSERT INTO class (age, name, sal) VALUES ($1, $2, $3) RETURNING id`,
&r.Age, &r.Name, &r.Sal).Scan(&r.ID)
iferr!=nil {
returnerrors.Wrap(err, "failed to insert class")
}
returnnil
}
// GetClassByPk select the Class from the database.funcGetClassByPk(dbQueryer, pk0int) (*Class, error) {
varrClasserr:=db.QueryRow(
`SELECT id, age, name, sal FROM class WHERE id = $1`,
pk0).Scan(&r.ID, &r.Age, &r.Name, &r.Sal)
iferr!=nil {
returnnil, errors.Wrap(err, "failed to select class")
}
return&r, nil
}
But I only want
type Class struct {
ID int
Age sql.NullInt64
Name sql.NullString
Sal sql.NullFloat64
}
The text was updated successfully, but these errors were encountered:
In the guide case I get:
But I only want
The text was updated successfully, but these errors were encountered: