liborm

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APP                      = "request.APP"
	USER                     = "request.USER"
	MODULE                   = "request.MODULE"
	METHOD                   = "request.METHOD"
	SetCommandError          = "error in Dml->SetTrxVariable(%s,%s,%s)"
	ErrorExecuteDML          = "ERROR_EXECUTE_DML"
	OracleSetVariableCommand = `--sql
		BEGIN 
			AUDIT_TRAIL.SET_MODIF_ARGS(:1, :2);
		END;`
	PostgresSetVariableCommand = "SELECT set_config($1,$2,true);"
	MySQLSetVariableCommand    = "SET @%s = '%s';"
	SQLiteSetVariableCommand   = "PRAGMA %s = '%s';"
)

Variables

This section is empty.

Functions

func GetQuery

func GetQuery[R any](query string, core OrmInterface, args ...any) ([]R, error)

func Query

func Query[R any](command libQuery.CommandInterface, core OrmInterface, args ...any) ([]R, error)

func QueryToStruct

func QueryToStruct[Target any](db *gorm.DB, querySql string, args ...any) ([]Target, error)

func SetVariable

func SetVariable(ctx context.Context, tx *gorm.DB, command, key, value string) error

Types

type ContextKey

type ContextKey string

type OrmInterface

type OrmInterface interface {
	GetDbMode() libQuery.DBMode
	GetDB() *gorm.DB
}

type OrmModel

type OrmModel struct {
	DB          *gorm.DB
	ProgramName string
	ModuleName  string
	SetVariable string
	Mode        libQuery.DBMode
}

func Init

func Init(
	DB *gorm.DB,
	ProgramName string,
	ModuleName string,
	mode libQuery.DBMode) (*OrmModel, error)

func (OrmModel) Dml

func (m OrmModel) Dml(ctx context.Context, moduleName, methodName, command string, args ...any) (int64, error)

func (OrmModel) GetDB

func (m OrmModel) GetDB() *gorm.DB

func (OrmModel) GetDbMode

func (m OrmModel) GetDbMode() libQuery.DBMode

func (OrmModel) SetModifVariables

func (m OrmModel) SetModifVariables(ctx context.Context, moduleName, methodName string, tx *gorm.DB) error

Jump to

Keyboard shortcuts

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