Documentation
¶
Overview ¶
Package db provides type-safe database queries.
Index ¶
- type CreateUserParams
- type DB
- type Organization
- type Queries
- func (q *Queries) CreateOrganization(ctx context.Context, name string) (Organization, error)
- func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
- func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)
- func (q *Queries) ListUsersByOrg(ctx context.Context, orgID int64) ([]User, error)
- func (q *Queries) WithTx(tx *sql.Tx) *Queries
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateUserParams ¶
type CreateUserParams struct {
OrgID int64 `json:"org_id"`
Email string `json:"email"`
FullName string `json:"full_name"`
}
CreateUserParams contains parameters for creating a new user.
type DB ¶
type DB interface {
ExecContext(context.Context, string, ...any) (sql.Result, error)
PrepareContext(context.Context, string) (*sql.Stmt, error)
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...any) *sql.Row
}
DB represents a database connection or transaction.
type Organization ¶
type Organization struct {
ID int64 `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
}
Organization represents an organization record.
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
Queries provides query execution methods.
func (*Queries) CreateOrganization ¶
CreateOrganization inserts a new organization and returns the created record.
func (*Queries) CreateUser ¶
CreateUser inserts a new user and returns the created record.
func (*Queries) GetUserByEmail ¶
GetUserByEmail fetches a user matching the provided email address.
func (*Queries) ListUsersByOrg ¶
ListUsersByOrg returns all users belonging to an organization.
Click to show internal directories.
Click to hide internal directories.