sqlc

package
v0.2.19-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sqlc provides a set of custom database queries and utilities for interacting with the SQL database used in the application. It includes generated code from sqlc as well as custom wrappers to handle different database backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID             int64
	ChannelPoint   string
	ShortChannelID int64
	PeerID         int64
}

type ChannelEvent

type ChannelEvent struct {
	ID               int64
	ChannelID        int64
	EventType        int16
	Timestamp        time.Time
	LocalBalanceSat  sql.NullInt64
	RemoteBalanceSat sql.NullInt64
	IsSync           bool
}

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 GetChannelEventsParams

type GetChannelEventsParams struct {
	ChannelID   int64
	ID          int64
	Timestamp   time.Time
	Timestamp_2 time.Time
	Limit       int32
}

type GetChannelsRow

type GetChannelsRow struct {
	ID             int64
	ShortChannelID int64
	Pubkey         string
}

type GetLatestChannelEventBeforeParams

type GetLatestChannelEventBeforeParams struct {
	ChannelID int64
	EventType int16
	Timestamp time.Time
}

type InsertChannelEventParams

type InsertChannelEventParams struct {
	ChannelID        int64
	EventType        int16
	Timestamp        time.Time
	LocalBalanceSat  sql.NullInt64
	RemoteBalanceSat sql.NullInt64
	IsSync           bool
}

type InsertChannelParams

type InsertChannelParams struct {
	ChannelPoint   string
	ShortChannelID int64
	PeerID         int64
}

type Peer

type Peer struct {
	ID     int64
	Pubkey string
}

type Querier

type Querier interface {
	GetChannelByChanPoint(ctx context.Context, channelPoint string) (Channel, error)
	GetChannelByShortChanID(ctx context.Context, shortChannelID int64) (Channel, error)
	GetChannelEvents(ctx context.Context, arg GetChannelEventsParams) ([]ChannelEvent, error)
	GetChannels(ctx context.Context) ([]GetChannelsRow, error)
	GetLatestChannelEventBefore(ctx context.Context, arg GetLatestChannelEventBeforeParams) (ChannelEvent, error)
	GetPeerByPubKey(ctx context.Context, pubkey string) (Peer, error)
	InsertChannel(ctx context.Context, arg InsertChannelParams) (int64, error)
	InsertChannelEvent(ctx context.Context, arg InsertChannelEventParams) error
	InsertPeer(ctx context.Context, pubkey string) (int64, error)
	// PruneChannelEventsByAge enforces the retention window on the channel_events
	// table, returning the number of rows deleted. It deletes any row whose
	// timestamp predates the given cutoff.
	PruneChannelEventsByAge(ctx context.Context, timestamp time.Time) (int64, error)
	// PruneChannelEventsBySize enforces the size ceiling on the channel_events
	// table, returning the number of rows deleted. It keeps the newest rows by
	// deleting everything with a smaller (earlier-inserted) id than the id found at
	// the given offset from the newest row, so an offset of (max-events - 1) keeps
	// exactly max-events rows.
	PruneChannelEventsBySize(ctx context.Context, offset int32) (int64, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func NewForType

func NewForType(db DBTX, typ sqldb.BackendType) *Queries

NewForType creates a new Queries instance for the given database type.

func (*Queries) Backend

func (q *Queries) Backend() sqldb.BackendType

Backend returns the type of database backend we're using.

func (*Queries) GetChannelByChanPoint

func (q *Queries) GetChannelByChanPoint(ctx context.Context, channelPoint string) (Channel, error)

func (*Queries) GetChannelByShortChanID

func (q *Queries) GetChannelByShortChanID(ctx context.Context, shortChannelID int64) (Channel, error)

func (*Queries) GetChannelEvents

func (q *Queries) GetChannelEvents(ctx context.Context, arg GetChannelEventsParams) ([]ChannelEvent, error)

func (*Queries) GetChannels

func (q *Queries) GetChannels(ctx context.Context) ([]GetChannelsRow, error)

func (*Queries) GetLatestChannelEventBefore

func (q *Queries) GetLatestChannelEventBefore(ctx context.Context, arg GetLatestChannelEventBeforeParams) (ChannelEvent, error)

func (*Queries) GetPeerByPubKey

func (q *Queries) GetPeerByPubKey(ctx context.Context, pubkey string) (Peer, error)

func (*Queries) InsertChannel

func (q *Queries) InsertChannel(ctx context.Context, arg InsertChannelParams) (int64, error)

func (*Queries) InsertChannelEvent

func (q *Queries) InsertChannelEvent(ctx context.Context, arg InsertChannelEventParams) error

func (*Queries) InsertPeer

func (q *Queries) InsertPeer(ctx context.Context, pubkey string) (int64, error)

func (*Queries) PruneChannelEventsByAge

func (q *Queries) PruneChannelEventsByAge(ctx context.Context, timestamp time.Time) (int64, error)

PruneChannelEventsByAge enforces the retention window on the channel_events table, returning the number of rows deleted. It deletes any row whose timestamp predates the given cutoff.

func (*Queries) PruneChannelEventsBySize

func (q *Queries) PruneChannelEventsBySize(ctx context.Context, offset int32) (int64, error)

PruneChannelEventsBySize enforces the size ceiling on the channel_events table, returning the number of rows deleted. It keeps the newest rows by deleting everything with a smaller (earlier-inserted) id than the id found at the given offset from the newest row, so an offset of (max-events - 1) keeps exactly max-events rows.

func (*Queries) WithTx

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

Jump to

Keyboard shortcuts

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