Documentation
¶
Index ¶
- Constants
- func AnyToAnys(a any) []any
- func ConvertParams(v any, escaper string) string
- func DeleteByIdSQL(tableName string) string
- func DeleteSQL(tableName, column string) string
- func ExistsByFilterExprs(db *sql.DB, tableName string, filters FilterExprs) (bool, error)
- func ExistsByFilterExprsSQL(tableName string, filters FilterExprs) string
- func ExistsByQuerySQL(qsql string) string
- func ExistsSQL(tableName, column string, withDeletedAt bool) string
- func StringConvertFor[T any](str string) (T, error)
- type Array
- type ConditionOperation
- type ConditionTag
- type Cursor
- type FilterExpr
- type FilterExprMap
- type FilterExprs
- type FloatArray
- type Id
- type IntArray
- type Json
- type List
- type MapJson
- type Null
- type NullJson
- type OTelDBStats
- type Ordered
- type Pagination
- type PaginationEmbedded
- type Range
- type RangeMode
- type RawJson
- type Sort
- type SortExpr
- type SortType
- type Sorts
- type StringArray
- type TimeArray
Constants ¶
const ( Mysql = "mysql" Postgres = "postgres" Sqlite = "sqlite" )
const ( TmFmtWithMS = "2006-01-02 15:04:05.999" NullStr = "NULL" )
const ( ColumnDeletedAt = "deleted_at" ColumnId = "id" ColumnName = "name" )
const ( ExprEqual = " = ?" ExprNotEqual = " != ?" ExprGreater = " > ?" )
const ( Insert = "INSERT" Select = "SELECT" Update = "UPDATE" Delete = "DELETE" LeftJoin = "LEFT JOIN" RightJoin = "RIGHT JOIN" InnerJoin = "INNER JOIN" Limit = `LIMIT %d` Offset = `OFFSET %d` Limit1 = `LIMIT 1` )
const ( NotDeleted = ColumnDeletedAt + " IS " + NullStr WithNotDeleted = ` AND ` + NotDeleted )
const ( IdEqual = ColumnId + ExprEqual NameEqual = ColumnName + ExprEqual )
const (
CondiTagName = "sqlcond" // e.g: `sqlcond:"column:id;operate:="`
)
const ScopeName = "github.com/hopeio/gox/database/sql"
Variables ¶
This section is empty.
Functions ¶
func ConvertParams ¶
ConvertParams converts the value.
func DeleteByIdSQL ¶
DeleteByIdSQL removes or resets state.
func ExistsByFilterExprs ¶
ExistsByFilterExprs performs the operation.
func ExistsByFilterExprsSQL ¶
func ExistsByFilterExprsSQL(tableName string, filters FilterExprs) string
ExistsByFilterExprsSQL returns the result.
func ExistsByQuerySQL ¶
ExistsByQuerySQL returns the result.
func StringConvertFor ¶
StringConvertFor performs the operation.
Types ¶
type Array ¶ added in v1.10.0
type Array[T any] []T
Array represents a PostgreSQL array for T. It implements the ArrayGetter and ArraySetter interfaces. It preserves PostgreSQL dimensions and custom lower bounds. Use FlatArray if these are not needed. only support number
type ConditionOperation ¶
type ConditionOperation int
const ( OperationPlace ConditionOperation = iota Equal NotEqual Greater Less Between GreaterOrEqual LessOrEqual IsNotNull IsNull In NotIn Like NotLike )
func ParseConditionOperation ¶
func ParseConditionOperation(op string) ConditionOperation
ParseConditionOperation parses the input.
func (ConditionOperation) String ¶
func (m ConditionOperation) String() string
String returns the string representation.
type ConditionTag ¶
type ConditionTag struct {
Column string `meta:"column"`
Operate string `meta:"operate"`
EmptyValid bool `meta:"emptyvalid"`
}
func GetConditionTagTag ¶ added in v1.6.11
func GetConditionTagTag(tag reflect.StructTag) (*ConditionTag, error)
GetConditionTagTag returns the value.
type FilterExpr ¶
type FilterExpr struct {
Field string `json:"field,omitempty"`
Operation ConditionOperation `json:"op,omitempty"`
Value any `json:"value,omitempty"`
}
type FilterExprMap ¶ added in v1.7.0
type FilterExprMap map[string]FilterExpr
type FilterExprs ¶
type FilterExprs []FilterExpr
func (FilterExprs) BuildSQL ¶
func (f FilterExprs) BuildSQL() (string, []any)
BuildSQL creates and returns a new instance.
type FloatArray ¶ added in v1.10.0
type FloatArray[T constraints.Float] []T
func (*FloatArray[T]) Scan ¶ added in v1.10.0
func (d *FloatArray[T]) Scan(value any) error
Scan performs the operation.
type IntArray ¶ added in v1.10.0
type IntArray[T constraints.Integer] []T
adpter postgres
type Json ¶ added in v1.10.0
type Json[T any] struct { V T }
type List ¶ added in v1.7.0
type List struct {
Pagination Pagination `json:"page,omitempty"`
Sort Sorts `json:"sort,omitempty"`
Filters FilterExprs `json:"filters,omitempty"`
}
type MapJson ¶ added in v1.10.0
type Null ¶ added in v1.10.0
func (Null[T]) MarshalJSON ¶ added in v1.10.0
MarshalJSON encodes the value.
func (*Null[T]) UnmarshalJSON ¶ added in v1.10.0
UnmarshalJSON decodes into the value.
type NullJson ¶ added in v1.10.0
func (*NullJson[T]) GormDataType ¶ added in v1.10.0
GormDataType returns the result.
type OTelDBStats ¶ added in v1.10.3
type OTelDBStats struct {
// contains filtered or unexported fields
}
func GlobalOTelDBStats ¶ added in v1.11.0
func GlobalOTelDBStats() *OTelDBStats
GlobalOTelDBStats returns the result.
func (*OTelDBStats) Close ¶ added in v1.10.3
func (s *OTelDBStats) Close() error
Close closes and releases resources.
type Pagination ¶ added in v1.7.0
type PaginationEmbedded ¶ added in v1.7.0
type RangeMode ¶ added in v1.7.0
type RangeMode int8
func (RangeMode) ContainsBegin ¶ added in v1.7.0
ContainsBegin reports whether the condition holds.
func (RangeMode) ContainsEnd ¶ added in v1.7.0
ContainsEnd reports whether the condition holds.
type RawJson ¶ added in v1.10.0
type RawJson []byte
func (*RawJson) GormDataType ¶ added in v1.10.0
GormDataType returns the result.
type StringArray ¶ added in v1.10.0
type StringArray []string
func (*StringArray) Scan ¶ added in v1.10.0
func (d *StringArray) Scan(value any) error
Scan performs the operation.