Documentation
¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type Connection
- type CreateChatRow
- type DBQuerier
- func (q *DBQuerier) CreateChat(ctx context.Context, chatID int64) (CreateChatRow, error)
- func (q *DBQuerier) CreateChatBatch(batch genericBatch, chatID int64)
- func (q *DBQuerier) CreateChatScan(results pgx.BatchResults) (CreateChatRow, error)
- func (q *DBQuerier) Delete(ctx context.Context, chatID int64) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteBatch(batch genericBatch, chatID int64)
- func (q *DBQuerier) DeleteScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) FindAllActiveChats(ctx context.Context) ([]FindAllActiveChatsRow, error)
- func (q *DBQuerier) FindAllActiveChatsBatch(batch genericBatch)
- func (q *DBQuerier) FindAllActiveChatsScan(results pgx.BatchResults) ([]FindAllActiveChatsRow, error)
- func (q *DBQuerier) FindByID(ctx context.Context, id int64) (FindByIDRow, error)
- func (q *DBQuerier) FindByIDBatch(batch genericBatch, id int64)
- func (q *DBQuerier) FindByIDScan(results pgx.BatchResults) (FindByIDRow, error)
- func (q *DBQuerier) FindByTgID(ctx context.Context, chatID int64) (FindByTgIDRow, error)
- func (q *DBQuerier) FindByTgIDBatch(batch genericBatch, chatID int64)
- func (q *DBQuerier) FindByTgIDScan(results pgx.BatchResults) (FindByTgIDRow, error)
- func (q *DBQuerier) UndeleteChat(ctx context.Context, chatID int64) (pgconn.CommandTag, error)
- func (q *DBQuerier) UndeleteChatBatch(batch genericBatch, chatID int64)
- func (q *DBQuerier) UndeleteChatScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type FindAllActiveChatsRow
- type FindByIDRow
- type FindByTgIDRow
- type Querier
- type QuerierConfig
- type Repository
- func (r *Repository) Create(ctx context.Context, chatId int64) (CreateChatDTO, error)
- func (r *Repository) Delete(ctx context.Context, chatId int64) error
- func (r *Repository) FindAllActiveChats(ctx context.Context) ([]*ModelDTO, error)
- func (r *Repository) FindByID(ctx context.Context, chatId int64) (*ModelDTO, error)
- func (r *Repository) FindByTelegramID(ctx context.Context, id int64) (*ModelDTO, error)
- func (r *Repository) RestoreFromDeleted(ctx context.Context, id int64) error
- func (r *Repository) Session(ctx context.Context, fn func(session Storage) error) error
- func (r *Repository) UpdateChatGroup(ctx context.Context, id int64, group *int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareAllQueries ¶
PrepareAllQueries executes a PREPARE statement for all pggen generated SQL queries in querier files. Typical usage is as the AfterConnect callback for pgxpool.Config
pgx will use the prepared statement if available. Calling PrepareAllQueries is an optional optimization to avoid a network round-trip the first time pgx runs a query if pgx statement caching is enabled.
Types ¶
type Connection ¶
type CreateChatRow ¶
type CreateChatRow struct { ID int64 `json:"id"` CreatedAt pgtype.Timestamptz `json:"created_at"` }
type DBQuerier ¶
type DBQuerier struct {
// contains filtered or unexported fields
}
func NewQuerier ¶
func NewQuerier(conn genericConn) *DBQuerier
NewQuerier creates a DBQuerier that implements Querier. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
func NewQuerierConfig ¶
func NewQuerierConfig(conn genericConn, cfg QuerierConfig) *DBQuerier
NewQuerierConfig creates a DBQuerier that implements Querier with the given config. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
func (*DBQuerier) CreateChat ¶
CreateChat implements Querier.CreateChat.
func (*DBQuerier) CreateChatBatch ¶
CreateChatBatch implements Querier.CreateChatBatch.
func (*DBQuerier) CreateChatScan ¶
func (q *DBQuerier) CreateChatScan(results pgx.BatchResults) (CreateChatRow, error)
CreateChatScan implements Querier.CreateChatScan.
func (*DBQuerier) DeleteBatch ¶
DeleteBatch implements Querier.DeleteBatch.
func (*DBQuerier) DeleteScan ¶
func (q *DBQuerier) DeleteScan(results pgx.BatchResults) (pgconn.CommandTag, error)
DeleteScan implements Querier.DeleteScan.
func (*DBQuerier) FindAllActiveChats ¶
func (q *DBQuerier) FindAllActiveChats(ctx context.Context) ([]FindAllActiveChatsRow, error)
FindAllActiveChats implements Querier.FindAllActiveChats.
func (*DBQuerier) FindAllActiveChatsBatch ¶
func (q *DBQuerier) FindAllActiveChatsBatch(batch genericBatch)
FindAllActiveChatsBatch implements Querier.FindAllActiveChatsBatch.
func (*DBQuerier) FindAllActiveChatsScan ¶
func (q *DBQuerier) FindAllActiveChatsScan(results pgx.BatchResults) ([]FindAllActiveChatsRow, error)
FindAllActiveChatsScan implements Querier.FindAllActiveChatsScan.
func (*DBQuerier) FindByIDBatch ¶
FindByIDBatch implements Querier.FindByIDBatch.
func (*DBQuerier) FindByIDScan ¶
func (q *DBQuerier) FindByIDScan(results pgx.BatchResults) (FindByIDRow, error)
FindByIDScan implements Querier.FindByIDScan.
func (*DBQuerier) FindByTgID ¶
FindByTgID implements Querier.FindByTgID.
func (*DBQuerier) FindByTgIDBatch ¶
FindByTgIDBatch implements Querier.FindByTgIDBatch.
func (*DBQuerier) FindByTgIDScan ¶
func (q *DBQuerier) FindByTgIDScan(results pgx.BatchResults) (FindByTgIDRow, error)
FindByTgIDScan implements Querier.FindByTgIDScan.
func (*DBQuerier) UndeleteChat ¶
UndeleteChat implements Querier.UndeleteChat.
func (*DBQuerier) UndeleteChatBatch ¶
UndeleteChatBatch implements Querier.UndeleteChatBatch.
func (*DBQuerier) UndeleteChatScan ¶
func (q *DBQuerier) UndeleteChatScan(results pgx.BatchResults) (pgconn.CommandTag, error)
UndeleteChatScan implements Querier.UndeleteChatScan.
type FindAllActiveChatsRow ¶
type FindAllActiveChatsRow struct { ID int64 `json:"id"` ChatID int64 `json:"chat_id"` GroupID int `json:"group_id"` CreatedAt pgtype.Timestamptz `json:"created_at"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` }
type FindByIDRow ¶
type FindByIDRow struct { ID int64 `json:"id"` ChatID int64 `json:"chat_id"` GroupID int `json:"group_id"` CreatedAt pgtype.Timestamptz `json:"created_at"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` }
type FindByTgIDRow ¶
type FindByTgIDRow struct { ID int64 `json:"id"` ChatID int64 `json:"chat_id"` GroupID int `json:"group_id"` CreatedAt pgtype.Timestamptz `json:"created_at"` DeletedAt pgtype.Timestamptz `json:"deleted_at"` }
type Querier ¶
type Querier interface { CreateChat(ctx context.Context, chatID int64) (CreateChatRow, error) // CreateChatBatch enqueues a CreateChat query into batch to be executed // later by the batch. CreateChatBatch(batch genericBatch, chatID int64) // CreateChatScan scans the result of an executed CreateChatBatch query. CreateChatScan(results pgx.BatchResults) (CreateChatRow, error) FindByTgID(ctx context.Context, chatID int64) (FindByTgIDRow, error) // FindByTgIDBatch enqueues a FindByTgID query into batch to be executed // later by the batch. FindByTgIDBatch(batch genericBatch, chatID int64) // FindByTgIDScan scans the result of an executed FindByTgIDBatch query. FindByTgIDScan(results pgx.BatchResults) (FindByTgIDRow, error) FindByID(ctx context.Context, id int64) (FindByIDRow, error) // FindByIDBatch enqueues a FindByID query into batch to be executed // later by the batch. FindByIDBatch(batch genericBatch, id int64) // FindByIDScan scans the result of an executed FindByIDBatch query. FindByIDScan(results pgx.BatchResults) (FindByIDRow, error) FindAllActiveChats(ctx context.Context) ([]FindAllActiveChatsRow, error) // FindAllActiveChatsBatch enqueues a FindAllActiveChats query into batch to be executed // later by the batch. FindAllActiveChatsBatch(batch genericBatch) // FindAllActiveChatsScan scans the result of an executed FindAllActiveChatsBatch query. FindAllActiveChatsScan(results pgx.BatchResults) ([]FindAllActiveChatsRow, error) UndeleteChat(ctx context.Context, chatID int64) (pgconn.CommandTag, error) // UndeleteChatBatch enqueues a UndeleteChat query into batch to be executed // later by the batch. UndeleteChatBatch(batch genericBatch, chatID int64) // UndeleteChatScan scans the result of an executed UndeleteChatBatch query. UndeleteChatScan(results pgx.BatchResults) (pgconn.CommandTag, error) Delete(ctx context.Context, chatID int64) (pgconn.CommandTag, error) // DeleteBatch enqueues a Delete query into batch to be executed // later by the batch. DeleteBatch(batch genericBatch, chatID int64) // DeleteScan scans the result of an executed DeleteBatch query. DeleteScan(results pgx.BatchResults) (pgconn.CommandTag, error) }
Querier is a typesafe Go interface backed by SQL queries.
Methods ending with Batch enqueue a query to run later in a pgx.Batch. After calling SendBatch on pgx.Conn, pgxpool.Pool, or pgx.Tx, use the Scan methods to parse the results.
type QuerierConfig ¶
type QuerierConfig struct { // DataTypes contains pgtype.Value to use for encoding and decoding instead // of pggen-generated pgtype.ValueTranscoder. // // If OIDs are available for an input parameter type and all of its // transitive dependencies, pggen will use the binary encoding format for // the input parameter. DataTypes []pgtype.DataType }
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(conn Connection) *Repository
func (*Repository) Create ¶
func (r *Repository) Create(ctx context.Context, chatId int64) (CreateChatDTO, error)
func (*Repository) FindAllActiveChats ¶
func (r *Repository) FindAllActiveChats(ctx context.Context) ([]*ModelDTO, error)
func (*Repository) FindByID ¶
func (r *Repository) FindByID(ctx context.Context, chatId int64) (*ModelDTO, error)
func (*Repository) FindByTelegramID ¶
func (r *Repository) FindByTelegramID(ctx context.Context, id int64) (*ModelDTO, error)
func (*Repository) RestoreFromDeleted ¶
func (r *Repository) RestoreFromDeleted(ctx context.Context, id int64) error
func (*Repository) Session ¶
func (r *Repository) Session(ctx context.Context, fn func(session Storage) error) error