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 }