db/migrations/0001_users.up.sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email VARCHAR(255),
age INTEGER,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
db/queries/users.sql
-- sgl.query(GetUser, one)
SELECT id, name, email, age, created_at
FROM users WHERE id = $1;
internal/store/users.sql.go
// Code generated by sgl. DO NOT EDIT.
type GetUserRow struct {
ID int32
Name string
Email *string
Age *int32
CreatedAt time.Time
}
func (queries *Queries) GetUser(
ctx context.Context, id int32,
) (GetUserRow, error)
* email and age can be NULL, so they are pointers. The others never are.