Documentation ¶
Index ¶
- func PrepareAllQueries(ctx context.Context, p preparer) error
- type Connection
- type CreateJobParams
- type DBQuerier
- func (q *DBQuerier) CountInChat(ctx context.Context, chatID int64) (int64, error)
- func (q *DBQuerier) CountInChatBatch(batch genericBatch, chatID int64)
- func (q *DBQuerier) CountInChatScan(results pgx.BatchResults) (int64, error)
- func (q *DBQuerier) CreateJob(ctx context.Context, params CreateJobParams) (int64, error)
- func (q *DBQuerier) CreateJobBatch(batch genericBatch, params CreateJobParams)
- func (q *DBQuerier) CreateJobScan(results pgx.BatchResults) (int64, error)
- func (q *DBQuerier) Delete(ctx context.Context, id int64) (pgconn.CommandTag, error)
- func (q *DBQuerier) DeleteBatch(batch genericBatch, id int64)
- func (q *DBQuerier) DeleteScan(results pgx.BatchResults) (pgconn.CommandTag, error)
- func (q *DBQuerier) FindAtTime(ctx context.Context, at time.Time) ([]FindAtTimeRow, error)
- func (q *DBQuerier) FindAtTimeBatch(batch genericBatch, at time.Time)
- func (q *DBQuerier) FindAtTimeScan(results pgx.BatchResults) ([]FindAtTimeRow, error)
- func (q *DBQuerier) FindByChat(ctx context.Context, chatID int64) ([]FindByChatRow, error)
- func (q *DBQuerier) FindByChatBatch(batch genericBatch, chatID int64)
- func (q *DBQuerier) FindByChatScan(results pgx.BatchResults) ([]FindByChatRow, 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) FindInPeriod(ctx context.Context, at time.Time, period time.Duration) ([]FindInPeriodRow, error)
- func (q *DBQuerier) FindInPeriodBatch(batch genericBatch, at time.Time, period time.Duration)
- func (q *DBQuerier) FindInPeriodScan(results pgx.BatchResults) ([]FindInPeriodRow, error)
- func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error)
- type FindAtTimeRow
- type FindByChatRow
- type FindByIDRow
- type FindInPeriodRow
- type Querier
- type QuerierConfig
- type Repository
- func (r *Repository) CountInChat(ctx context.Context, chatId int64) (int64, error)
- func (r *Repository) Delete(ctx context.Context, cronId int64) error
- func (r *Repository) FindAtTime(ctx context.Context, at time.Time) ([]scheduler.CronJob, error)
- func (r *Repository) FindByChat(ctx context.Context, chatId int64) ([]scheduler.CronJob, error)
- func (r *Repository) FindByID(ctx context.Context, chatId int64) (*scheduler.CronJob, error)
- func (r *Repository) FindInPeriod(ctx context.Context, at time.Time, periodRange time.Duration) ([]scheduler.CronJob, error)
- func (r *Repository) Insert(ctx context.Context, cron scheduler.CronJob) (int64, error)
- func (r *Repository) Update(ctx context.Context, job scheduler.CronJob) 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 Connection genericConn
type CreateJobParams ¶
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) CountInChat ¶
CountInChat implements Querier.CountInChat.
func (*DBQuerier) CountInChatBatch ¶
CountInChatBatch implements Querier.CountInChatBatch.
func (*DBQuerier) CountInChatScan ¶
CountInChatScan implements Querier.CountInChatScan.
func (*DBQuerier) CreateJobBatch ¶
func (q *DBQuerier) CreateJobBatch(batch genericBatch, params CreateJobParams)
CreateJobBatch implements Querier.CreateJobBatch.
func (*DBQuerier) CreateJobScan ¶
CreateJobScan implements Querier.CreateJobScan.
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) FindAtTime ¶
FindAtTime implements Querier.FindAtTime.
func (*DBQuerier) FindAtTimeBatch ¶
FindAtTimeBatch implements Querier.FindAtTimeBatch.
func (*DBQuerier) FindAtTimeScan ¶
func (q *DBQuerier) FindAtTimeScan(results pgx.BatchResults) ([]FindAtTimeRow, error)
FindAtTimeScan implements Querier.FindAtTimeScan.
func (*DBQuerier) FindByChat ¶
FindByChat implements Querier.FindByChat.
func (*DBQuerier) FindByChatBatch ¶
FindByChatBatch implements Querier.FindByChatBatch.
func (*DBQuerier) FindByChatScan ¶
func (q *DBQuerier) FindByChatScan(results pgx.BatchResults) ([]FindByChatRow, error)
FindByChatScan implements Querier.FindByChatScan.
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) FindInPeriod ¶
func (q *DBQuerier) FindInPeriod(ctx context.Context, at time.Time, period time.Duration) ([]FindInPeriodRow, error)
FindInPeriod implements Querier.FindInPeriod.
func (*DBQuerier) FindInPeriodBatch ¶
FindInPeriodBatch implements Querier.FindInPeriodBatch.
func (*DBQuerier) FindInPeriodScan ¶
func (q *DBQuerier) FindInPeriodScan(results pgx.BatchResults) ([]FindInPeriodRow, error)
FindInPeriodScan implements Querier.FindInPeriodScan.
type FindAtTimeRow ¶
type FindByChatRow ¶
type FindByIDRow ¶
type FindInPeriodRow ¶
type Querier ¶
type Querier interface { CreateJob(ctx context.Context, params CreateJobParams) (int64, error) // CreateJobBatch enqueues a CreateJob query into batch to be executed // later by the batch. CreateJobBatch(batch genericBatch, params CreateJobParams) // CreateJobScan scans the result of an executed CreateJobBatch query. CreateJobScan(results pgx.BatchResults) (int64, 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) FindInPeriod(ctx context.Context, at time.Time, period time.Duration) ([]FindInPeriodRow, error) // FindInPeriodBatch enqueues a FindInPeriod query into batch to be executed // later by the batch. FindInPeriodBatch(batch genericBatch, at time.Time, period time.Duration) // FindInPeriodScan scans the result of an executed FindInPeriodBatch query. FindInPeriodScan(results pgx.BatchResults) ([]FindInPeriodRow, error) CountInChat(ctx context.Context, chatID int64) (int64, error) // CountInChatBatch enqueues a CountInChat query into batch to be executed // later by the batch. CountInChatBatch(batch genericBatch, chatID int64) // CountInChatScan scans the result of an executed CountInChatBatch query. CountInChatScan(results pgx.BatchResults) (int64, error) FindByChat(ctx context.Context, chatID int64) ([]FindByChatRow, error) // FindByChatBatch enqueues a FindByChat query into batch to be executed // later by the batch. FindByChatBatch(batch genericBatch, chatID int64) // FindByChatScan scans the result of an executed FindByChatBatch query. FindByChatScan(results pgx.BatchResults) ([]FindByChatRow, error) FindAtTime(ctx context.Context, at time.Time) ([]FindAtTimeRow, error) // FindAtTimeBatch enqueues a FindAtTime query into batch to be executed // later by the batch. FindAtTimeBatch(batch genericBatch, at time.Time) // FindAtTimeScan scans the result of an executed FindAtTimeBatch query. FindAtTimeScan(results pgx.BatchResults) ([]FindAtTimeRow, error) Delete(ctx context.Context, id int64) (pgconn.CommandTag, error) // DeleteBatch enqueues a Delete query into batch to be executed // later by the batch. DeleteBatch(batch genericBatch, id 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