common

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 0 Imported by: 0

README

common

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIContext added in v0.1.0

APIContext combines request and response contexts

type APIContextKey added in v0.1.0

type APIContextKey struct{}

type ColumnDataType

type ColumnDataType string

type DatabaseType

type DatabaseType string

type GlobalThisReader

type GlobalThisReader interface {
	Input() any
	Env() map[string]any
	Metas() map[string]any
	Session() map[string]any
	RequestHeaders() map[string]any

	Output() any
	ResponseHeaders() map[string]any
}

type MutableRequestContext added in v0.1.0

type MutableRequestContext interface {
	SetRequestID(string)
	SetMethod(string)
	SetParams(any)
	SetRawParams([]byte)
	SetMetas(map[string]any)
}

MutableRequestContext allows modification of request context

type MutableResponseContext added in v0.1.0

type MutableResponseContext interface {
	SetResult(any)
	SetErr(error)
}

MutableResponseContext allows modification of response context

type PersistenceContext

type PersistenceContext interface {
	GetRepository(entity string) (Repository, error)
	GetAllQueryCount() int64
	CloseAllTxn(error) error
}

type PreparedQuery

type PreparedQuery struct {
	Query     string    `json:"query"`
	Bind      []any     `json:"bind"`
	QueryType QueryType `json:"queryType"`

	CheckPoint      []*PreparedQuery `json:"checkPoint"`
	DatabaseUpdater []*PreparedQuery `json:"databaseUpdater"`
	ResultEnricher  []*PreparedQuery `json:"resultEnricher"`
}

type QueryResult

type QueryResult struct {
	Row          map[string]any
	Rows         []map[string]any
	RowsAffected int64
	LastInsertId int64
	Total        int64
}

type QueryType

type QueryType string

type Repository

type Repository interface {
	BindNamed(query string, arg any) (string, []any, error)
	Find(query string, args ...any) (map[string]any, error)
	FindAll(query string, args ...any) ([]map[string]any, error)
	Insert(query string, args ...any) (int64, error)
	InsertBatch(query string, args ...any) (int64, error)
	// InsertNamedBatch
	// Deprecated
	InsertNamedBatch(query string, args []any) (int64, error)
	Update(query string, args ...any) (int64, error)
	Delete(query string, args ...any) (int64, error)

	Begin() error
	Commit() error
	Rollback() error

	Exec(query string, args ...any) error

	DriverName() string

	QueryTotal() int64
	SetTraceId(traceId string)
}

type RequestContext added in v0.1.0

type RequestContext interface {
	RequestID() string
	Method() string
	Params() any
	RawParams() []byte
	Metas() map[string]any
}

RequestContext contains request-related information

type ResponseContext added in v0.1.0

type ResponseContext interface {
	Result() any
	Err() error
}

ResponseContext contains response-related information

type ScriptRunner

type ScriptRunner interface {
	RunScript(globalThis map[string]any, pCtx PersistenceContext, sourceCode string) (any, error)
}

type TableType

type TableType string

Jump to

Keyboard shortcuts

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