db

package module
v8.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 13 Imported by: 4

README

DB

XORM Plugin

Import
import (
    "github.com/fuyibing/db/v8"
)

Documentation

Overview

Package db database plugin based on xorm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transaction

func Transaction(ctx context.Context, handlers ...TransactionHandler) error

func TransactionWithSession

func TransactionWithSession(ctx context.Context, sess *xorm.Session, handlers ...TransactionHandler) (err error)

Types

type Configuration

type Configuration struct {
	Databases map[string]*Database `yaml:"databases"`
	// contains filtered or unexported fields
}
var Config *Configuration

func (*Configuration) GetDatabase

func (o *Configuration) GetDatabase(key string) *Database

func (*Configuration) GetDefault

func (o *Configuration) GetDefault() *Database

func (*Configuration) SetDatabase

func (o *Configuration) SetDatabase(key string, database *Database)

type Connection

type Connection struct {
	// contains filtered or unexported fields
}
var Connector *Connection

func (*Connection) GetEngineGroup

func (o *Connection) GetEngineGroup(keys ...string) (engine *xorm.EngineGroup)

func (*Connection) GetMaster

func (o *Connection) GetMaster(keys ...string) *xorm.Session

func (*Connection) GetMasterWithContext

func (o *Connection) GetMasterWithContext(ctx context.Context, keys ...string) *xorm.Session

func (*Connection) GetSlave

func (o *Connection) GetSlave(keys ...string) *xorm.Session

func (*Connection) GetSlaveWithContext

func (o *Connection) GetSlaveWithContext(ctx context.Context, keys ...string) *xorm.Session

type Database

type Database struct {
	Driver        string   `yaml:"driver"`
	Dsn           []string `yaml:"dsn"`
	MaxIdle       int      `yaml:"max-idle"`
	MaxLifetime   int      `yaml:"max-lifetime"`
	MaxOpen       int      `yaml:"max-open"`
	Mapper        string   `yaml:"mapper"`
	EnableSession *bool    `yaml:"enable-session"`
	ShowSQL       *bool    `yaml:"show-sql"`
	// contains filtered or unexported fields
}

func (*Database) GetDataName

func (o *Database) GetDataName() string

func (*Database) GetMapper

func (o *Database) GetMapper() names.Mapper

func (*Database) GetUsername

func (o *Database) GetUsername() string

func (*Database) Undefined

func (o *Database) Undefined() bool

type Service

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

func (*Service) Master

func (o *Service) Master() *xorm.Session

func (*Service) Slave

func (o *Service) Slave() *xorm.Session

func (*Service) Use

func (o *Service) Use(sessions ...*xorm.Session)

func (*Service) UseConnection

func (o *Service) UseConnection(connection string)

type TransactionHandler

type TransactionHandler func(ctx context.Context, sess *xorm.Session) error

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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