sqlite

package
v0.0.0-...-dc3c4d4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(
	db *gorm.DB, idDESC bool, offset, limit int, destSlice interface{},
) (total int64, err error)

func ListByOrder

func ListByOrder(
	db *gorm.DB, orderBy string, offset, limit int, destSlice interface{},
) (total int64, err error)

Types

type Config

type Config struct {
	Database string `default:"file::memory:?cache=shared"`
	// For shared memory sqlite instance, never expire the connection otherwise
	// the memory db may be released once no connection existed.
	ConnMaxLifetime time.Duration `default:"0"`
	MaxOpenConns    int           `default:"10"`
	MaxIdleConns    int           `default:"10"`
}

Config represents the sqlite configurations to open a database instance.

func MustNewConfigFromViper

func MustNewConfigFromViper() Config

MustNewConfigFromViper creates an instance of Config from Viper.

func (*Config) MustNewDB

func (config *Config) MustNewDB(database string) *gorm.DB

func (*Config) MustOpenOrCreate

func (config *Config) MustOpenOrCreate(tables ...interface{}) *SqliteStore

MustOpenOrCreate creates an instance of store or exits on any error.

type Crud

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

func NewCrud

func NewCrud(store *SqliteStore, errEntityNotFound, errEntityAlreadyExists error) *Crud

func (*Crud) Exists

func (crud *Crud) Exists(modelPtr interface{}, whereQuery string, args ...interface{}) (bool, error)

func (*Crud) Get

func (crud *Crud) Get(modelPtr interface{}, whereQuery string, args ...interface{}) error

func (*Crud) GetById

func (crud *Crud) GetById(modelPtr interface{}, id uint64) error

func (*Crud) List

func (crud *Crud) List(db *gorm.DB, idDESC bool, offset, limit int, destSlice interface{}) (total int64, err error)

func (*Crud) ListByOrder

func (*Crud) ListByOrder(db *gorm.DB, orderBy string, offset, limit int, destSlice interface{}) (total int64, err error)

func (*Crud) RequireAbsent

func (crud *Crud) RequireAbsent(modelPtr interface{}, whereQuery string, args ...interface{}) error

type SqliteStore

type SqliteStore struct {
	*gorm.DB
}

func MustNewStoreFromViper

func MustNewStoreFromViper(tables ...interface{}) *SqliteStore

func NewSqliteStore

func NewSqliteStore(db *gorm.DB) *SqliteStore

func (*SqliteStore) Close

func (ms *SqliteStore) Close() error

func (*SqliteStore) GetBill

func (ms *SqliteStore) GetBill(app, addr string, status int) (*model.Bill, bool, error)

func (*SqliteStore) GetBillFee

func (ms *SqliteStore) GetBillFee(app, addr string) (*big.Int, error)

func (*SqliteStore) IsRecordNotFound

func (ms *SqliteStore) IsRecordNotFound(err error) bool

func (*SqliteStore) UpsertBill

func (ms *SqliteStore) UpsertBill(tx *gorm.DB, app, addr string, fee *big.Int) (*model.Bill, error)

Jump to

Keyboard shortcuts

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