Documentation ¶
Index ¶
- func ExecuteReadQuery(ctx context.Context, query string, conn *sql.Conn, lim int64) ([]map[string]any, error)
- func ExecuteWriteQuery(ctx context.Context, query string, conn *sql.Conn) (sql.Result, error)
- func GenerateDBFieldMap(doc any) map[string]reflect.Value
- func GenerateDeleteQuery(table, id string) string
- func GenerateInsertQuery(tableName string, record map[string]any) string
- func GenerateReadQuery(tableName string, filter map[string]any) string
- func GenerateTableName(table interface{}) string
- func GenerateUpdateQuery(table string, id string, record map[string]any) string
- func GenerateWhereClauseFromFilter(filter any) string
- func GenerateWhereClauseFromID(id any) string
- func GetPostgresConnection(cfg PostgresConfig) (*sql.Conn, error)
- func HandleSliceAny(v []any) string
- func IsZeroValue(value any) bool
- func MapToRecord(record map[string]any) (*pb.RecordResponse, error)
- func MapsToRecords(records []map[string]any) (*pb.RecordsResponse, error)
- func ScanSingleRow(rows *sql.Rows, fieldMap map[string]reflect.Value) error
- func SyncTable(ctx context.Context, conn *sql.Conn, table any) error
- type PostgresConfig
- type Statement
- func (stmt Statement) AddWhereClause(cond string) string
- func (stmt Statement) AllCols() Statement
- func (stmt Statement) CheckWhereClauseNotEmpty() error
- func (stmt Statement) Columns(cols ...string) Statement
- func (stmt Statement) ExecuteInsertQuery(ctx context.Context, conn *sql.Conn, tx *sql.Tx, query string) (any, error)
- func (stmt Statement) ExecuteReadQuery(ctx context.Context, conn *sql.Conn, tx *sql.Tx, query string, doc any) error
- func (stmt Statement) ExecuteWriteQuery(ctx context.Context, conn *sql.Conn, tx *sql.Tx, query string) (sql.Result, error)
- func (stmt Statement) GenerateDeleteQuery() string
- func (stmt Statement) GenerateInsertQuery(doc any) string
- func (stmt Statement) GenerateReadQuery(doc any) string
- func (stmt Statement) GenerateUpdateQuery(doc any) string
- func (stmt Statement) GenerateWhereClause(filter ...any) Statement
- func (stmt Statement) ID(id any) Statement
- func (stmt Statement) In(col string, values ...any) Statement
- func (stmt Statement) MustCols(cols ...string) Statement
- func (stmt Statement) ShowSQL(showSQL bool) Statement
- func (stmt Statement) Table(name string) Statement
- func (stmt Statement) Where(cond string, args ...any) Statement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteReadQuery ¶
func ExecuteWriteQuery ¶
func GenerateDeleteQuery ¶
func GenerateTableName ¶
func GenerateTableName(table interface{}) string
func GenerateUpdateQuery ¶
func GetPostgresConnection ¶
func GetPostgresConnection(cfg PostgresConfig) (*sql.Conn, error)
func HandleSliceAny ¶
func IsZeroValue ¶
func MapToRecord ¶
func MapToRecord(record map[string]any) (*pb.RecordResponse, error)
func MapsToRecords ¶
func MapsToRecords(records []map[string]any) (*pb.RecordsResponse, error)
Types ¶
type PostgresConfig ¶
type PostgresConfig struct { Name string `json:"name" yaml:"name"` Host string `json:"host" yaml:"host"` Port string `json:"port" yaml:"port"` User string `json:"user" yaml:"user"` Password string `json:"password" yaml:"password"` SSLMode string `json:"sslmode" yaml:"sslmode"` }
func (PostgresConfig) String ¶
func (cp PostgresConfig) String() string
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
func (Statement) AddWhereClause ¶
func (Statement) CheckWhereClauseNotEmpty ¶
func (Statement) ExecuteInsertQuery ¶
func (Statement) ExecuteReadQuery ¶
func (Statement) ExecuteWriteQuery ¶
func (Statement) GenerateDeleteQuery ¶
func (Statement) GenerateInsertQuery ¶
func (Statement) GenerateReadQuery ¶
func (Statement) GenerateUpdateQuery ¶
func (Statement) GenerateWhereClause ¶
Click to show internal directories.
Click to hide internal directories.