dbx

package
v0.0.0-...-a092f05 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WrapErr     = func(err *Error) error { return err }
	Logger      func(format string, args ...interface{})
	ShouldRetry func(driver string, err error) bool
)

Functions

func DeleteAll

func DeleteAll(ctx context.Context, db *DB) (int64, error)

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError returns true if the error is a constraint error.

Types

type DB

type DB struct {
	tagsql.DB

	Hooks struct {
		Now func() time.Time
	}
	// contains filtered or unexported fields
}

func Open

func Open(driver, source string) (db *DB, err error)

func (*DB) Close

func (obj *DB) Close() (err error)

func (*DB) NewRx

func (obj *DB) NewRx() *Rx

func (*DB) Open

func (obj *DB) Open(ctx context.Context) (*Tx, error)

func (*DB) WithTx

func (db *DB) WithTx(ctx context.Context, fn func(context.Context, *Tx) error) (err error)

WithTx wraps DB code in a transaction.

type DBMethods

type DBMethods interface {
	Methods

	Schema() string
	Rebind(sql string) string
}

type Error

type Error struct {
	Err         error
	Code        ErrorCode
	Driver      string
	Constraint  string
	QuerySuffix string
}

func (*Error) Cause

func (e *Error) Cause() error

Cause returns the underlying error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

type ErrorCode

type ErrorCode int
const (
	ErrorCode_Unknown ErrorCode = iota
	ErrorCode_UnsupportedDriver
	ErrorCode_NoRows
	ErrorCode_TxDone
	ErrorCode_TooManyRows
	ErrorCode_ConstraintViolation
	ErrorCode_EmptyUpdate
)

type Methods

type Methods interface {
	All_Node_OrderBy_Desc_PinnedAt(ctx context.Context) (
		rows []*Node, err error)

	All_Pin_By_Cid_OrderBy_Desc_CreatedAt(ctx context.Context,
		pin_cid Pin_Cid_Field) (
		rows []*Pin, err error)

	All_Pin_By_Processed_Equal_False_And_Retry_Less_Number_OrderBy_Asc_CreatedAt(ctx context.Context) (
		rows []*Pin, err error)

	All_Pin_OrderBy_Desc_CreatedAt(ctx context.Context) (
		rows []*Pin, err error)

	Create_Node(ctx context.Context,
		node_cid Node_Cid_Field,
		node_days Node_Days_Field) (
		node *Node, err error)

	Create_Pin(ctx context.Context,
		pin_tx Pin_Tx_Field,
		pin_ix Pin_Ix_Field,
		pin_cid Pin_Cid_Field,
		pin_amount Pin_Amount_Field,
		optional Pin_Create_Fields) (
		pin *Pin, err error)

	Get_Node_By_Cid(ctx context.Context,
		node_cid Node_Cid_Field) (
		node *Node, err error)

	Get_Pin_By_Cid(ctx context.Context,
		pin_cid Pin_Cid_Field) (
		pin *Pin, err error)

	Update_Node_By_Cid(ctx context.Context,
		node_cid Node_Cid_Field,
		update Node_Update_Fields) (
		node *Node, err error)

	Update_Pin_By_Tx_And_Ix(ctx context.Context,
		pin_tx Pin_Tx_Field,
		pin_ix Pin_Ix_Field,
		update Pin_Update_Fields) (
		pin *Pin, err error)
}

type Node

type Node struct {
	Cid      string
	Days     int
	PinnedAt time.Time
}

type Node_Cid_Field

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

func Node_Cid

func Node_Cid(v string) Node_Cid_Field

type Node_Days_Field

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

func Node_Days

func Node_Days(v int) Node_Days_Field

type Node_PinnedAt_Field

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

func Node_PinnedAt

func Node_PinnedAt(v time.Time) Node_PinnedAt_Field

type Node_Update_Fields

type Node_Update_Fields struct {
	Days Node_Days_Field
}

type Pin

type Pin struct {
	Tx        string
	Ix        int
	Cid       string
	Retry     int
	Error     string
	Parse     bool
	Amount    string
	Processed bool
	CreatedAt time.Time
}

type Pin_Amount_Field

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

func Pin_Amount

func Pin_Amount(v string) Pin_Amount_Field

type Pin_Cid_Field

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

func Pin_Cid

func Pin_Cid(v string) Pin_Cid_Field

type Pin_Create_Fields

type Pin_Create_Fields struct {
	Retry     Pin_Retry_Field
	Error     Pin_Error_Field
	Parse     Pin_Parse_Field
	Processed Pin_Processed_Field
}

type Pin_CreatedAt_Field

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

func Pin_CreatedAt

func Pin_CreatedAt(v time.Time) Pin_CreatedAt_Field

type Pin_Error_Field

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

func Pin_Error

func Pin_Error(v string) Pin_Error_Field

type Pin_Ix_Field

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

func Pin_Ix

func Pin_Ix(v int) Pin_Ix_Field

type Pin_Parse_Field

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

func Pin_Parse

func Pin_Parse(v bool) Pin_Parse_Field

type Pin_Processed_Field

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

func Pin_Processed

func Pin_Processed(v bool) Pin_Processed_Field

type Pin_Retry_Field

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

func Pin_Retry

func Pin_Retry(v int) Pin_Retry_Field

type Pin_Tx_Field

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

func Pin_Tx

func Pin_Tx(v string) Pin_Tx_Field

type Pin_Update_Fields

type Pin_Update_Fields struct {
	Retry     Pin_Retry_Field
	Error     Pin_Error_Field
	Processed Pin_Processed_Field
}

type Rx

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

func (*Rx) All_Node_OrderBy_Desc_PinnedAt

func (rx *Rx) All_Node_OrderBy_Desc_PinnedAt(ctx context.Context) (
	rows []*Node, err error)

func (*Rx) All_Pin_By_Cid_OrderBy_Desc_CreatedAt

func (rx *Rx) All_Pin_By_Cid_OrderBy_Desc_CreatedAt(ctx context.Context,
	pin_cid Pin_Cid_Field) (
	rows []*Pin, err error)

func (*Rx) All_Pin_By_Processed_Equal_False_And_Retry_Less_Number_OrderBy_Asc_CreatedAt

func (rx *Rx) All_Pin_By_Processed_Equal_False_And_Retry_Less_Number_OrderBy_Asc_CreatedAt(ctx context.Context) (
	rows []*Pin, err error)

func (*Rx) All_Pin_OrderBy_Desc_CreatedAt

func (rx *Rx) All_Pin_OrderBy_Desc_CreatedAt(ctx context.Context) (
	rows []*Pin, err error)

func (*Rx) Commit

func (rx *Rx) Commit() (err error)

func (*Rx) Create_Node

func (rx *Rx) Create_Node(ctx context.Context,
	node_cid Node_Cid_Field,
	node_days Node_Days_Field) (
	node *Node, err error)

func (*Rx) Create_Pin

func (rx *Rx) Create_Pin(ctx context.Context,
	pin_tx Pin_Tx_Field,
	pin_ix Pin_Ix_Field,
	pin_cid Pin_Cid_Field,
	pin_amount Pin_Amount_Field,
	optional Pin_Create_Fields) (
	pin *Pin, err error)

func (*Rx) Get_Node_By_Cid

func (rx *Rx) Get_Node_By_Cid(ctx context.Context,
	node_cid Node_Cid_Field) (
	node *Node, err error)

func (*Rx) Get_Pin_By_Cid

func (rx *Rx) Get_Pin_By_Cid(ctx context.Context,
	pin_cid Pin_Cid_Field) (
	pin *Pin, err error)

func (*Rx) Rebind

func (rx *Rx) Rebind(s string) string

func (*Rx) Rollback

func (rx *Rx) Rollback() (err error)

func (*Rx) UnsafeTx

func (rx *Rx) UnsafeTx(ctx context.Context) (unsafe_tx tagsql.Tx, err error)

func (*Rx) Update_Node_By_Cid

func (rx *Rx) Update_Node_By_Cid(ctx context.Context,
	node_cid Node_Cid_Field,
	update Node_Update_Fields) (
	node *Node, err error)

func (*Rx) Update_Pin_By_Tx_And_Ix

func (rx *Rx) Update_Pin_By_Tx_And_Ix(ctx context.Context,
	pin_tx Pin_Tx_Field,
	pin_ix Pin_Ix_Field,
	update Pin_Update_Fields) (
	pin *Pin, err error)

type Tx

type Tx struct {
	Tx tagsql.Tx
	// contains filtered or unexported fields
}

type TxMethods

type TxMethods interface {
	Methods

	Rebind(s string) string
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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