db

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 3 Imported by: 0

README

SQL Queries

sqlc generates type-safe code from SQL. Here's how it works:

  1. You define the schema in schema.sql.
  2. You write your queries in query.sql using regular SQL.
  3. You run sqlc generate to generate Go code with type-safe interfaces to those queries.
  4. You write application code that calls the generated code.

Only those who need to create or update SQL queries will need to have sqlc installed on their system. It is not a dependency required to build the codebase.

Install sqlc

Snap

sudo snap install sqlc

Go install

go install github.com/kyleconroy/sqlc/cmd/sqlc@latest

macOS

brew install sqlc

Download a release

Visit https://github.com/kyleconroy/sqlc/releases to download a release for your environment.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddAccessTokenForUserParams added in v0.0.12

type AddAccessTokenForUserParams struct {
	Token  string
	UserID string
}

type AddAuthForUserParams added in v0.0.12

type AddAuthForUserParams struct {
	UserID string
	Token  string
	Type   string
}

type AddFollowerParams

type AddFollowerParams struct {
	Iri           string
	Inbox         string
	Request       string
	RequestObject []byte
	Name          sql.NullString
	Username      string
	Image         sql.NullString
	ApprovedAt    sql.NullTime
}

type AddNotificationParams added in v0.0.12

type AddNotificationParams struct {
	Channel     string
	Destination string
}

type AddToAcceptedActivitiesParams

type AddToAcceptedActivitiesParams struct {
	Iri       string
	Actor     string
	Type      string
	Timestamp time.Time
}

type AddToOutboxParams

type AddToOutboxParams struct {
	Iri              string
	Value            []byte
	Type             string
	LiveNotification sql.NullBool
}

type ApAcceptedActivity

type ApAcceptedActivity struct {
	ID        int32
	Iri       string
	Actor     string
	Type      string
	Timestamp time.Time
}

type ApFollower

type ApFollower struct {
	Iri           string
	Inbox         string
	Name          sql.NullString
	Username      string
	Image         sql.NullString
	Request       string
	RequestObject []byte
	CreatedAt     sql.NullTime
	ApprovedAt    sql.NullTime
	DisabledAt    sql.NullTime
}

type ApOutbox

type ApOutbox struct {
	Iri              string
	Value            []byte
	Type             string
	CreatedAt        sql.NullTime
	LiveNotification sql.NullBool
}

type ApproveFederationFollowerParams

type ApproveFederationFollowerParams struct {
	ApprovedAt sql.NullTime
	Iri        string
}

type Auth added in v0.0.12

type Auth struct {
	ID        int32
	UserID    string
	Token     string
	Type      string
	Timestamp time.Time
}

type BanIPAddressParams added in v0.0.12

type BanIPAddressParams struct {
	IpAddress string
	Notes     sql.NullString
}

type ChangeDisplayColorParams added in v0.1.0

type ChangeDisplayColorParams struct {
	DisplayColor int32
	ID           string
}

type ChangeDisplayNameParams added in v0.0.12

type ChangeDisplayNameParams struct {
	DisplayName   string
	PreviousNames sql.NullString
	NamechangedAt sql.NullTime
	ID            string
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DoesInboundActivityExistParams

type DoesInboundActivityExistParams struct {
	Iri   string
	Actor string
	Type  string
}

type GetFederationFollowerApprovalRequestsRow

type GetFederationFollowerApprovalRequestsRow struct {
	Iri       string
	Inbox     string
	Name      sql.NullString
	Username  string
	Image     sql.NullString
	CreatedAt sql.NullTime
}

type GetFederationFollowersWithOffsetParams

type GetFederationFollowersWithOffsetParams struct {
	Limit  int32
	Offset int32
}

type GetFederationFollowersWithOffsetRow

type GetFederationFollowersWithOffsetRow struct {
	Iri       string
	Inbox     string
	Name      sql.NullString
	Username  string
	Image     sql.NullString
	CreatedAt sql.NullTime
}

type GetInboundActivitiesWithOffsetParams

type GetInboundActivitiesWithOffsetParams struct {
	Limit  int32
	Offset int32
}

type GetInboundActivitiesWithOffsetRow

type GetInboundActivitiesWithOffsetRow struct {
	Iri       string
	Actor     string
	Type      string
	Timestamp time.Time
}

type GetMessagesFromUserRow added in v0.1.0

type GetMessagesFromUserRow struct {
	ID        string
	Body      sql.NullString
	HiddenAt  sql.NullTime
	Timestamp sql.NullTime
}

type GetObjectFromOutboxByIRIRow

type GetObjectFromOutboxByIRIRow struct {
	Value            []byte
	LiveNotification sql.NullBool
	CreatedAt        sql.NullTime
}

type GetOutboxWithOffsetParams

type GetOutboxWithOffsetParams struct {
	Limit  int32
	Offset int32
}

type GetRejectedAndBlockedFollowersRow

type GetRejectedAndBlockedFollowersRow struct {
	Iri        string
	Name       sql.NullString
	Username   string
	Image      sql.NullString
	CreatedAt  sql.NullTime
	DisabledAt sql.NullTime
}

type GetUserByAccessTokenRow added in v0.0.12

type GetUserByAccessTokenRow struct {
	ID              string
	DisplayName     string
	DisplayColor    int32
	CreatedAt       sql.NullTime
	DisabledAt      sql.NullTime
	PreviousNames   sql.NullString
	NamechangedAt   sql.NullTime
	AuthenticatedAt sql.NullTime
	Scopes          sql.NullString
}

type GetUserByAuthParams added in v0.0.12

type GetUserByAuthParams struct {
	Token string
	Type  string
}

type GetUserByAuthRow added in v0.0.12

type GetUserByAuthRow struct {
	ID              string
	DisplayName     string
	DisplayColor    int32
	CreatedAt       sql.NullTime
	DisabledAt      sql.NullTime
	PreviousNames   sql.NullString
	NamechangedAt   sql.NullTime
	AuthenticatedAt sql.NullTime
	Scopes          sql.NullString
}

type IpBan added in v0.0.12

type IpBan struct {
	IpAddress string
	Notes     sql.NullString
	CreatedAt sql.NullTime
}

type Message added in v0.1.0

type Message struct {
	ID        string
	UserID    sql.NullString
	Body      sql.NullString
	EventType sql.NullString
	HiddenAt  sql.NullTime
	Timestamp sql.NullTime
	Title     sql.NullString
	Subtitle  sql.NullString
	Image     sql.NullString
	Link      sql.NullString
}

type Notification added in v0.0.12

type Notification struct {
	ID          int32
	Channel     string
	Destination string
	CreatedAt   sql.NullTime
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddAccessTokenForUser added in v0.0.12

func (q *Queries) AddAccessTokenForUser(ctx context.Context, arg AddAccessTokenForUserParams) error

func (*Queries) AddAuthForUser added in v0.0.12

func (q *Queries) AddAuthForUser(ctx context.Context, arg AddAuthForUserParams) error

func (*Queries) AddFollower

func (q *Queries) AddFollower(ctx context.Context, arg AddFollowerParams) error

func (*Queries) AddNotification added in v0.0.12

func (q *Queries) AddNotification(ctx context.Context, arg AddNotificationParams) error

func (*Queries) AddToAcceptedActivities

func (q *Queries) AddToAcceptedActivities(ctx context.Context, arg AddToAcceptedActivitiesParams) error

func (*Queries) AddToOutbox

func (q *Queries) AddToOutbox(ctx context.Context, arg AddToOutboxParams) error

func (*Queries) ApproveFederationFollower

func (q *Queries) ApproveFederationFollower(ctx context.Context, arg ApproveFederationFollowerParams) error

func (*Queries) BanIPAddress added in v0.0.12

func (q *Queries) BanIPAddress(ctx context.Context, arg BanIPAddressParams) error

func (*Queries) ChangeDisplayColor added in v0.1.0

func (q *Queries) ChangeDisplayColor(ctx context.Context, arg ChangeDisplayColorParams) error

func (*Queries) ChangeDisplayName added in v0.0.12

func (q *Queries) ChangeDisplayName(ctx context.Context, arg ChangeDisplayNameParams) error

func (*Queries) DoesInboundActivityExist

func (q *Queries) DoesInboundActivityExist(ctx context.Context, arg DoesInboundActivityExistParams) (int64, error)

func (*Queries) GetFederationFollowerApprovalRequests

func (q *Queries) GetFederationFollowerApprovalRequests(ctx context.Context) ([]GetFederationFollowerApprovalRequestsRow, error)

func (*Queries) GetFollowerByIRI

func (q *Queries) GetFollowerByIRI(ctx context.Context, iri string) (ApFollower, error)

func (*Queries) GetFollowerCount

func (q *Queries) GetFollowerCount(ctx context.Context) (int64, error)

Queries added to query.sql must be compiled into Go code with sqlc. Read README.md for details. Federation related queries.

func (*Queries) GetIPAddressBans added in v0.0.12

func (q *Queries) GetIPAddressBans(ctx context.Context) ([]IpBan, error)

func (*Queries) GetInboundActivityCount added in v0.0.12

func (q *Queries) GetInboundActivityCount(ctx context.Context) (int64, error)

func (*Queries) GetLocalPostCount

func (q *Queries) GetLocalPostCount(ctx context.Context) (int64, error)

func (*Queries) GetMessagesFromUser added in v0.1.0

func (q *Queries) GetMessagesFromUser(ctx context.Context, userID sql.NullString) ([]GetMessagesFromUserRow, error)

func (*Queries) GetNotificationDestinationsForChannel added in v0.0.12

func (q *Queries) GetNotificationDestinationsForChannel(ctx context.Context, channel string) ([]string, error)

func (*Queries) GetObjectFromOutboxByIRI

func (q *Queries) GetObjectFromOutboxByIRI(ctx context.Context, iri string) (GetObjectFromOutboxByIRIRow, error)

func (*Queries) GetOutboxWithOffset

func (q *Queries) GetOutboxWithOffset(ctx context.Context, arg GetOutboxWithOffsetParams) ([][]byte, error)

func (*Queries) GetRejectedAndBlockedFollowers

func (q *Queries) GetRejectedAndBlockedFollowers(ctx context.Context) ([]GetRejectedAndBlockedFollowersRow, error)

func (*Queries) GetUserByAccessToken added in v0.0.12

func (q *Queries) GetUserByAccessToken(ctx context.Context, token string) (GetUserByAccessTokenRow, error)

func (*Queries) GetUserByAuth added in v0.0.12

func (q *Queries) GetUserByAuth(ctx context.Context, arg GetUserByAuthParams) (GetUserByAuthRow, error)

func (*Queries) GetUserDisplayNameByToken added in v0.0.12

func (q *Queries) GetUserDisplayNameByToken(ctx context.Context, token string) (string, error)

func (*Queries) IsDisplayNameAvailable added in v0.0.12

func (q *Queries) IsDisplayNameAvailable(ctx context.Context, displayName string) (int64, error)

func (*Queries) IsIPAddressBlocked added in v0.0.12

func (q *Queries) IsIPAddressBlocked(ctx context.Context, ipAddress string) (int64, error)

func (*Queries) RejectFederationFollower

func (q *Queries) RejectFederationFollower(ctx context.Context, arg RejectFederationFollowerParams) error

func (*Queries) RemoveFollowerByIRI

func (q *Queries) RemoveFollowerByIRI(ctx context.Context, iri string) error

func (*Queries) RemoveIPAddressBan added in v0.0.12

func (q *Queries) RemoveIPAddressBan(ctx context.Context, ipAddress string) error

func (*Queries) RemoveNotificationDestinationForChannel added in v0.0.12

func (q *Queries) RemoveNotificationDestinationForChannel(ctx context.Context, arg RemoveNotificationDestinationForChannelParams) error

func (*Queries) SetAccessTokenToOwner added in v0.0.12

func (q *Queries) SetAccessTokenToOwner(ctx context.Context, arg SetAccessTokenToOwnerParams) error

func (*Queries) SetUserAsAuthenticated added in v0.0.12

func (q *Queries) SetUserAsAuthenticated(ctx context.Context, id string) error

func (*Queries) UpdateFollowerByIRI

func (q *Queries) UpdateFollowerByIRI(ctx context.Context, arg UpdateFollowerByIRIParams) error

func (*Queries) WithTx

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

type RejectFederationFollowerParams

type RejectFederationFollowerParams struct {
	DisabledAt sql.NullTime
	Iri        string
}

type RemoveNotificationDestinationForChannelParams added in v0.0.12

type RemoveNotificationDestinationForChannelParams struct {
	Channel     string
	Destination string
}

type SetAccessTokenToOwnerParams added in v0.0.12

type SetAccessTokenToOwnerParams struct {
	UserID string
	Token  string
}

type UpdateFollowerByIRIParams

type UpdateFollowerByIRIParams struct {
	Inbox    string
	Name     sql.NullString
	Username string
	Image    sql.NullString
	Iri      string
}

type User added in v0.0.12

type User struct {
	ID              string
	DisplayName     string
	DisplayColor    int32
	CreatedAt       sql.NullTime
	DisabledAt      sql.NullTime
	PreviousNames   sql.NullString
	NamechangedAt   sql.NullTime
	Scopes          sql.NullString
	AuthenticatedAt sql.NullTime
	Type            sql.NullString
	LastUsed        interface{}
}

type UserAccessToken added in v0.0.12

type UserAccessToken struct {
	Token     string
	UserID    string
	Timestamp time.Time
}

Jump to

Keyboard shortcuts

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