lightning-terminal/db/sqlc/db_custom.go
Viktor Torstensson 03f4261714
multi: remove unused db code
As we've now switched over to using sqldb v2 for most of the db objects,
we can remove a lot of deprecated code that's no longer used in the litd
project. This commit removes that code.
2026-05-14 11:37:52 +02:00

48 lines
1.3 KiB
Go

package sqlc
import (
"context"
"github.com/lightningnetwork/lnd/sqldb/v2"
)
// wrappedTX is a wrapper around a DBTX that also stores the database backend
// type.
type wrappedTX struct {
DBTX
backendType sqldb.BackendType
}
// Backend returns the type of database backend we're using.
func (q *Queries) Backend() sqldb.BackendType {
wtx, ok := q.db.(*wrappedTX)
if !ok {
// Shouldn't happen unless a new database backend type is added
// but not initialized correctly.
return sqldb.BackendTypeUnknown
}
return wtx.backendType
}
// NewForType creates a new Queries instance for the given database type.
func NewForType(db DBTX, typ sqldb.BackendType) *Queries {
return &Queries{db: &wrappedTX{db, typ}}
}
// CustomQueries defines a set of custom queries that we define in addition
// to the ones generated by sqlc.
type CustomQueries interface {
// CountActions returns the number of actions that match the provided
// ActionQueryParams.
CountActions(ctx context.Context, arg ActionQueryParams) (int64, error)
// ListActions retrieves a list of actions based on the provided
// ListActionsParams.
ListActions(ctx context.Context,
arg ListActionsParams) ([]Action, error)
// Backend returns the type of the database backend used.
Backend() sqldb.BackendType
}