sqlc

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string
const (
	ActionTypeCREATE ActionType = "CREATE"
	ActionTypeREAD   ActionType = "READ"
	ActionTypeUPDATE ActionType = "UPDATE"
	ActionTypeDELETE ActionType = "DELETE"
	ActionTypeLIST   ActionType = "LIST"
)

func (*ActionType) Scan

func (e *ActionType) Scan(src interface{}) error

func (ActionType) Valid

func (e ActionType) Valid() bool

type AssignPermissionToRoleParams

type AssignPermissionToRoleParams struct {
	RoleID       uint32 `json:"roleId"`
	PermissionID uint32 `json:"permissionId"`
}

type AssignRoleToUserParams

type AssignRoleToUserParams struct {
	UserID uint32 `json:"userId"`
	RoleID uint32 `json:"roleId"`
}

type CreatePermissionParams

type CreatePermissionParams struct {
	Name        string       `json:"name"`
	Description *string      `json:"description"`
	Resource    ResourceType `json:"resource"`
	Action      ActionType   `json:"action"`
}

type CreateRoleParams

type CreateRoleParams struct {
	Name        string  `json:"name"`
	Description *string `json:"description"`
}

type CreateUserParams

type CreateUserParams struct {
	Username     string `json:"username"`
	PasswordHash string `json:"passwordHash"`
	Email        string `json:"email"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetPermissionByIDRow

type GetPermissionByIDRow struct {
	Name        string       `json:"name"`
	Description *string      `json:"description"`
	Resource    ResourceType `json:"resource"`
	Action      ActionType   `json:"action"`
}

type GetRoleByIDRow

type GetRoleByIDRow struct {
	Name        string  `json:"name"`
	Description *string `json:"description"`
}

type GetUserByEmailRow

type GetUserByEmailRow struct {
	ID           uint32             `json:"id"`
	PasswordHash string             `json:"passwordHash"`
	Username     string             `json:"username"`
	CreatedAt    pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt    pgtype.Timestamptz `json:"updatedAt"`
}

type GetUserByIDRow

type GetUserByIDRow struct {
	Username     string             `json:"username"`
	PasswordHash string             `json:"passwordHash"`
	Email        string             `json:"email"`
	CreatedAt    pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt    pgtype.Timestamptz `json:"updatedAt"`
}

type GetUserByUsernameRow

type GetUserByUsernameRow struct {
	ID           uint32             `json:"id"`
	PasswordHash string             `json:"passwordHash"`
	Email        string             `json:"email"`
	CreatedAt    pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt    pgtype.Timestamptz `json:"updatedAt"`
}

type ListRolesRow

type ListRolesRow struct {
	ID          uint32  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
}

type ListUsersRow

type ListUsersRow struct {
	ID        uint32             `json:"id"`
	Username  string             `json:"username"`
	Email     string             `json:"email"`
	CreatedAt pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt pgtype.Timestamptz `json:"updatedAt"`
}

type NullActionType

type NullActionType struct {
	ActionType ActionType `json:"actionType"`
	Valid      bool       `json:"valid"` // Valid is true if ActionType is not NULL
}

func (*NullActionType) Scan

func (ns *NullActionType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullActionType) Value

func (ns NullActionType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullResourceType

type NullResourceType struct {
	ResourceType ResourceType `json:"resourceType"`
	Valid        bool         `json:"valid"` // Valid is true if ResourceType is not NULL
}

func (*NullResourceType) Scan

func (ns *NullResourceType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullResourceType) Value

func (ns NullResourceType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Permission

type Permission struct {
	ID          uint32             `json:"id"`
	Name        string             `json:"name"`
	Description *string            `json:"description"`
	Resource    ResourceType       `json:"resource"`
	Action      ActionType         `json:"action"`
	CreatedAt   pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt   pgtype.Timestamptz `json:"updatedAt"`
}

type Querier

type Querier interface {
	AssignPermissionToRole(ctx context.Context, arg AssignPermissionToRoleParams) error
	AssignRoleToUser(ctx context.Context, arg AssignRoleToUserParams) error
	CreatePermission(ctx context.Context, arg CreatePermissionParams) error
	CreateRole(ctx context.Context, arg CreateRoleParams) error
	CreateUser(ctx context.Context, arg CreateUserParams) (uint32, error)
	DeletePermission(ctx context.Context, id uint32) error
	DeleteRole(ctx context.Context, id uint32) error
	DeleteUser(ctx context.Context, id uint32) error
	GetPermissionByID(ctx context.Context, id uint32) (*GetPermissionByIDRow, error)
	GetRoleByID(ctx context.Context, id uint32) (*GetRoleByIDRow, error)
	GetRolePermissions(ctx context.Context, roleID uint32) ([]*Permission, error)
	GetUserByEmail(ctx context.Context, email string) (*GetUserByEmailRow, error)
	GetUserByID(ctx context.Context, id uint32) (*GetUserByIDRow, error)
	GetUserByUsername(ctx context.Context, username string) (*GetUserByUsernameRow, error)
	GetUserRoles(ctx context.Context, userID uint32) ([]*Role, error)
	ListRoles(ctx context.Context) ([]*ListRolesRow, error)
	ListUsers(ctx context.Context) ([]*ListUsersRow, error)
	RemovePermissionFromRole(ctx context.Context, arg RemovePermissionFromRoleParams) error
	RemoveRoleFromUser(ctx context.Context, arg RemoveRoleFromUserParams) error
	UpdateUserEmail(ctx context.Context, arg UpdateUserEmailParams) error
	UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error
	UpdateUsername(ctx context.Context, arg UpdateUsernameParams) error
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AssignPermissionToRole

func (q *Queries) AssignPermissionToRole(ctx context.Context, arg AssignPermissionToRoleParams) error

func (*Queries) AssignRoleToUser

func (q *Queries) AssignRoleToUser(ctx context.Context, arg AssignRoleToUserParams) error

func (*Queries) CreatePermission

func (q *Queries) CreatePermission(ctx context.Context, arg CreatePermissionParams) error

func (*Queries) CreateRole

func (q *Queries) CreateRole(ctx context.Context, arg CreateRoleParams) error

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (uint32, error)

func (*Queries) DeletePermission

func (q *Queries) DeletePermission(ctx context.Context, id uint32) error

func (*Queries) DeleteRole

func (q *Queries) DeleteRole(ctx context.Context, id uint32) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id uint32) error

func (*Queries) GetPermissionByID

func (q *Queries) GetPermissionByID(ctx context.Context, id uint32) (*GetPermissionByIDRow, error)

func (*Queries) GetRoleByID

func (q *Queries) GetRoleByID(ctx context.Context, id uint32) (*GetRoleByIDRow, error)

func (*Queries) GetRolePermissions

func (q *Queries) GetRolePermissions(ctx context.Context, roleID uint32) ([]*Permission, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (*GetUserByEmailRow, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id uint32) (*GetUserByIDRow, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (*GetUserByUsernameRow, error)

func (*Queries) GetUserRoles

func (q *Queries) GetUserRoles(ctx context.Context, userID uint32) ([]*Role, error)

func (*Queries) ListRoles

func (q *Queries) ListRoles(ctx context.Context) ([]*ListRolesRow, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context) ([]*ListUsersRow, error)

func (*Queries) RemovePermissionFromRole

func (q *Queries) RemovePermissionFromRole(ctx context.Context, arg RemovePermissionFromRoleParams) error

func (*Queries) RemoveRoleFromUser

func (q *Queries) RemoveRoleFromUser(ctx context.Context, arg RemoveRoleFromUserParams) error

func (*Queries) UpdateUserEmail

func (q *Queries) UpdateUserEmail(ctx context.Context, arg UpdateUserEmailParams) error

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) UpdateUsername

func (q *Queries) UpdateUsername(ctx context.Context, arg UpdateUsernameParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RemovePermissionFromRoleParams

type RemovePermissionFromRoleParams struct {
	RoleID       uint32 `json:"roleId"`
	PermissionID uint32 `json:"permissionId"`
}

type RemoveRoleFromUserParams

type RemoveRoleFromUserParams struct {
	UserID uint32 `json:"userId"`
	RoleID uint32 `json:"roleId"`
}

type ResourceType

type ResourceType string
const (
	ResourceTypeUSER       ResourceType = "USER"
	ResourceTypeROLE       ResourceType = "ROLE"
	ResourceTypePERMISSION ResourceType = "PERMISSION"
	ResourceTypePRODUCT    ResourceType = "PRODUCT"
	ResourceTypeORDER      ResourceType = "ORDER"
)

func (*ResourceType) Scan

func (e *ResourceType) Scan(src interface{}) error

func (ResourceType) Valid

func (e ResourceType) Valid() bool

type Role

type Role struct {
	ID          uint32             `json:"id"`
	Name        string             `json:"name"`
	Description *string            `json:"description"`
	CreatedAt   pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt   pgtype.Timestamptz `json:"updatedAt"`
}

type RolePermission

type RolePermission struct {
	RoleID       uint32 `json:"roleId"`
	PermissionID uint32 `json:"permissionId"`
}

type UpdateUserEmailParams

type UpdateUserEmailParams struct {
	ID    uint32 `json:"id"`
	Email string `json:"email"`
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	ID           uint32 `json:"id"`
	PasswordHash string `json:"passwordHash"`
}

type UpdateUsernameParams

type UpdateUsernameParams struct {
	ID       uint32 `json:"id"`
	Username string `json:"username"`
}

type User

type User struct {
	ID           uint32             `json:"id"`
	Username     string             `json:"username"`
	PasswordHash string             `json:"passwordHash"`
	Email        string             `json:"email"`
	CreatedAt    pgtype.Timestamptz `json:"createdAt"`
	UpdatedAt    pgtype.Timestamptz `json:"updatedAt"`
}

type UserRole

type UserRole struct {
	UserID uint32 `json:"userId"`
	RoleID uint32 `json:"roleId"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL