Documentation ¶
Index ¶
- Constants
- func CallSql[R any](query string, core QueryRunnerInterface, args ...any) (int, string, string, []R, error)
- func ConvertJsonToStruct[Q any](row string) (Q, error)
- func DBModeStrings() []string
- func DmlCommandTypeStrings() []string
- func Fill[Data any](query string, core QueryRunnerInterface, args ...any) ([]Data, string, string, error)
- func Filler[Data any](query string, core QueryRunnerInterface, args ...any) (Data, string, string, error)
- func GetDBTagValue(name string, s any) (*string, *string, error)
- func GetFormTagValue(name string, s any) (*string, *string, error)
- func GetLocalArgs(parser webFramework.RequestParser, args []any) []any
- func GetOutArgs(parser webFramework.RequestParser, args ...any) map[string]string
- func GetQuery[R any](query string, core QueryRunnerInterface, args ...any) ([]R, response.ErrorState)
- func GetQueryResp[R any](query string, core QueryRunnerInterface, args ...any) (int, string, string, bool, any, error)
- func GetTagValue(name, tag string, s any) (*string, *string, error)
- func HandleCheckDuplicate(code int, desc, dupDesc string, record []QueryData, err error) (int, string, error)
- func HandleCheckExistence(code int, desc, notExistDesc string, record []QueryData, err error) (int, string, error)
- func ParseCommand(command, user, app, action, title string, value map[string]string, ...) string
- func ParseMap[Target any](input map[string]any) (*Target, error)
- func ParseQueryResult(result map[string]any, t reflect.Type, v reflect.Value)
- func PrepareArgs(args []any) []any
- func Query[Result QueryResult](core QueryRunnerInterface, command QueryCommand, args ...any) (any, response.ErrorState)
- func QueryCommandTypeStrings() []string
- func QueryToStruct[Target any](q QueryRunnerInterface, querySql string, args ...any) ([]Target, error)
- func SerializeArray(arr []any) string
- func SerializeStringArray(arr []string) string
- func SetVariable(ctx context.Context, tx *sql.Tx, command, key, value string) error
- type ContextKey
- type DBMode
- type DmlCommand
- type DmlCommandType
- type DmlModel
- type DmlResult
- type QueryCommand
- type QueryCommandType
- type QueryData
- type QueryRequest
- type QueryResult
- type QueryRunnerInterface
- type QueryRunnerModel
- func (m QueryRunnerModel) CallDbFunction(callString string, args ...any) (int, string, error)
- func (m QueryRunnerModel) Close()
- func (m QueryRunnerModel) Dml(ctx context.Context, moduleName, methodName, command string, args ...any) (sql.Result, error)
- func (m QueryRunnerModel) GetModule() (string, string)
- func (m QueryRunnerModel) InsertRow(insert string, args ...any) (sql.Result, error)
- func (m QueryRunnerModel) NewStatement(command string) (*sql.Stmt, error)
- func (m QueryRunnerModel) QueryRunner(querySql string, args ...any) (int, []map[string]any, error)
- func (m QueryRunnerModel) QueryToStruct(querySql string, target any, args ...any) (int, any, error)
- func (m QueryRunnerModel) SetModifVariables(ctx context.Context, moduleName, methodName string, tx *sql.Tx) error
- func (m QueryRunnerModel) SetVariableCommand() string
- type QueryWithDeps
- type RecordDataDml
- type RecordDataGet
- type Updatable
Constants ¶
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 CARD_ISSUE.AUDIT_TRAIL.SET_MODIF_ARGS(:1, :2); END;` PostgresSetVariableCommand = "SELECT set_config($1,$2,true);" )
const ( PREPARE_ERROR = -1 QUERY_ERROR = -2 PARSE_ERROR = -3 SCAN_ERROR = -4 )
const ( NO_DATA_FOUND = "NO_DATA_FOUND" NO_DATA_FOUND_DESC = "رکوردی یافت نشد" DUPLICATE_FOUND = "DUPLICATE_FOUND" DUPLICATE_FOUND_DESC = "رکورد تکراری است" DB_READ_ERROR = "DB_READ_ERROR" PARSE_DB_RESP_ERROR = "PARSE_DB_RESP_ERROR" )
const (
ERROR_CALLING_DB_FUNCTION = "ERROR_CALLING_DB_FUNCTION"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertJsonToStruct ¶
func DBModeStrings ¶ added in v0.6.3
func DBModeStrings() []string
DBModeStrings returns a slice of all String values of the enum
func DmlCommandTypeStrings ¶ added in v0.5.0
func DmlCommandTypeStrings() []string
DmlCommandTypeStrings returns a slice of all String values of the enum
func GetDBTagValue ¶ added in v0.9.22
func GetFormTagValue ¶ added in v0.9.22
func GetLocalArgs ¶ added in v0.9.49
func GetLocalArgs(parser webFramework.RequestParser, args []any) []any
func GetOutArgs ¶ added in v0.9.33
func GetOutArgs(parser webFramework.RequestParser, args ...any) map[string]string
func GetQuery ¶ added in v0.9.20
func GetQuery[R any](query string, core QueryRunnerInterface, args ...any) ([]R, response.ErrorState)
func GetQueryResp ¶
func GetTagValue ¶ added in v0.9.22
func HandleCheckDuplicate ¶
func HandleCheckExistence ¶ added in v0.3.6
func ParseCommand ¶
func ParseCommand(command, user, app, action, title string, value map[string]string, parser webFramework.FieldParser) string
func ParseQueryResult ¶
func PrepareArgs ¶ added in v0.6.10
func Query ¶ added in v0.5.0
func Query[Result QueryResult](core QueryRunnerInterface, command QueryCommand, args ...any) (any, response.ErrorState)
func QueryCommandTypeStrings ¶ added in v0.5.0
func QueryCommandTypeStrings() []string
QueryCommandTypeStrings returns a slice of all String values of the enum
func QueryToStruct ¶ added in v0.10.28
func QueryToStruct[Target any](q QueryRunnerInterface, querySql string, args ...any) ([]Target, error)
func SerializeArray ¶ added in v0.6.10
func SerializeStringArray ¶ added in v0.6.10
Types ¶
type ContextKey ¶ added in v0.6.1
type ContextKey string
type DBMode ¶ added in v0.6.3
type DBMode int
func DBModeString ¶ added in v0.6.3
DBModeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func DBModeValues ¶ added in v0.6.3
func DBModeValues() []DBMode
DBModeValues returns all values of the enum
func (DBMode) IsADBMode ¶ added in v0.6.3
IsADBMode returns "true" if the value is listed in the enum definition. "false" otherwise
func (DBMode) MarshalJSON ¶ added in v0.6.3
MarshalJSON implements the json.Marshaler interface for DBMode
func (*DBMode) UnmarshalJSON ¶ added in v0.6.3
UnmarshalJSON implements the json.Unmarshaler interface for DBMode
type DmlCommand ¶ added in v0.4.21
type DmlCommand struct { Name string Command string Args []any Type DmlCommandType CustomError response.ErrorState }
func (DmlCommand) Execute ¶ added in v0.4.21
func (command DmlCommand) Execute(core QueryRunnerInterface, moduleName, methodName string) (any, response.ErrorState)
func (DmlCommand) ExecuteWithContext ¶ added in v0.6.1
func (command DmlCommand) ExecuteWithContext(parser webFramework.RequestParser, ctx context.Context, moduleName, methodName string, core QueryRunnerInterface) (any, response.ErrorState)
type DmlCommandType ¶ added in v0.5.0
type DmlCommandType int
const ( QueryCheckNotExists DmlCommandType = iota QueryCheckExists Insert Update Delete )
func DmlCommandTypeString ¶ added in v0.5.0
func DmlCommandTypeString(s string) (DmlCommandType, error)
DmlCommandTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func DmlCommandTypeValues ¶ added in v0.5.0
func DmlCommandTypeValues() []DmlCommandType
DmlCommandTypeValues returns all values of the enum
func (DmlCommandType) IsADmlCommandType ¶ added in v0.5.0
func (i DmlCommandType) IsADmlCommandType() bool
IsADmlCommandType returns "true" if the value is listed in the enum definition. "false" otherwise
func (DmlCommandType) MarshalJSON ¶ added in v0.5.0
func (i DmlCommandType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for DmlCommandType
func (DmlCommandType) String ¶ added in v0.5.0
func (i DmlCommandType) String() string
func (*DmlCommandType) UnmarshalJSON ¶ added in v0.5.0
func (i *DmlCommandType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for DmlCommandType
type DmlModel ¶ added in v0.4.21
type DmlModel interface { PreControlCommands() map[string][]DmlCommand DmlCommands() map[string][]DmlCommand FinalizeCommands() map[string][]DmlCommand }
type DmlResult ¶
type DmlResult struct { Rows map[string]string `json:"rows" form:"rows"` LastInsertId int64 `json:"lastId" form:"lastId"` RowsAffected int64 `json:"rowsAffected" form:"rowsAffected"` }
func GetDmlResult ¶ added in v0.8.5
func (*DmlResult) LoadFromMap ¶
type QueryCommand ¶ added in v0.5.0
type QueryCommand struct { Name string Command string Type QueryCommandType Args []string }
func (QueryCommand) GetDriverArgs ¶ added in v0.9.21
func (q QueryCommand) GetDriverArgs(req any) []driver.Value
type QueryCommandType ¶ added in v0.5.0
type QueryCommandType int
const ( QuerySingle QueryCommandType = iota QueryAll QueryMap Transforms )
func QueryCommandTypeString ¶ added in v0.5.0
func QueryCommandTypeString(s string) (QueryCommandType, error)
QueryCommandTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func QueryCommandTypeValues ¶ added in v0.5.0
func QueryCommandTypeValues() []QueryCommandType
QueryCommandTypeValues returns all values of the enum
func (QueryCommandType) IsAQueryCommandType ¶ added in v0.5.0
func (i QueryCommandType) IsAQueryCommandType() bool
IsAQueryCommandType returns "true" if the value is listed in the enum definition. "false" otherwise
func (QueryCommandType) MarshalJSON ¶ added in v0.5.0
func (i QueryCommandType) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for QueryCommandType
func (QueryCommandType) String ¶ added in v0.5.0
func (i QueryCommandType) String() string
func (*QueryCommandType) UnmarshalJSON ¶ added in v0.5.0
func (i *QueryCommandType) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for QueryCommandType
type QueryRequest ¶ added in v0.5.4
type QueryResult ¶ added in v0.5.0
type QueryRunnerInterface ¶
type QueryRunnerInterface interface { NewStatement(command string) (*sql.Stmt, error) QueryRunner(querySql string, args ...any) (int, []map[string]any, error) QueryToStruct(querySql string, target any, args ...any) (int, any, error) CallDbFunction(callString string, args ...any) (int, string, error) GetModule() (string, string) InsertRow(insert string, args ...any) (sql.Result, error) Dml(ctx context.Context, moduleName, methodName, command string, args ...any) (sql.Result, error) SetVariableCommand() string //Used in mock db for test Close() }
type QueryRunnerModel ¶
type QueryRunnerModel struct { DB *sql.DB ProgramName string ModuleName string SetVariable string Mode DBMode }
func (QueryRunnerModel) CallDbFunction ¶
func (QueryRunnerModel) Close ¶ added in v0.9.1
func (m QueryRunnerModel) Close()
func (QueryRunnerModel) GetModule ¶
func (m QueryRunnerModel) GetModule() (string, string)
func (QueryRunnerModel) NewStatement ¶ added in v0.10.28
func (m QueryRunnerModel) NewStatement(command string) (*sql.Stmt, error)
func (QueryRunnerModel) QueryRunner ¶
func (QueryRunnerModel) QueryToStruct ¶
func (QueryRunnerModel) SetModifVariables ¶ added in v0.6.1
func (QueryRunnerModel) SetVariableCommand ¶ added in v0.6.1
func (m QueryRunnerModel) SetVariableCommand() string
type QueryWithDeps ¶
type QueryWithDeps interface {
GetFillable(core QueryRunnerInterface) (map[string]any, error)
}
type RecordDataDml ¶
type RecordDataDml interface { SetId(string) CheckDuplicate(core QueryRunnerInterface) (int, string, error) Filler(headers map[string][]string, core QueryRunnerInterface, args ...any) (string, error) Post(core QueryRunnerInterface, args map[string]string) (DmlResult, int, string, error) CheckExistence(core QueryRunnerInterface) (int, string, error) PreControl(core QueryRunnerInterface) (int, string, error) Put(core QueryRunnerInterface, args map[string]string) (DmlResult, int, string, error) }