db

package
v0.0.0-...-9528f6d Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a wrapper around *ent.Client.

func New

func New(opt *Option) (*DB, error)

New returns a new DB instance.

func (*DB) Client

func (db *DB) Client() *ent.Client

Client returns the underlying *ent.Client.

func (*DB) Close

func (db *DB) Close() error

Close closes the database client.

func (*DB) WithTx

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

WithTx runs the given function in a transaction.

type Option

type Option struct {
	Driver string
	Dns    string
	Debug  bool
}

Option represents the options for the DB.

type TxFunc

type TxFunc func(tx *ent.Tx) error

TxFunc is the function type used by WithTx.

Jump to

Keyboard shortcuts

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