Documentation
¶
Index ¶
- Constants
- func ConvertParams(v interface{}, escaper string) string
- func DeleteByIdSQL(tableName string) string
- func DeleteSQL(tableName, column string) string
- func ExistsByFilterExprsSQL(tableName string, filters FilterExprs) string
- func ExistsByQuerySQL(qsql string) string
- func ExistsSQL(tableName, column string, withDeletedAt bool) string
- type ConditionOperation
- type ConditionTag
- type FilterExpr
- type FilterExprs
Constants ¶
View Source
const ( TmFmtWithMS = "2006-01-02 15:04:05.999" NullStr = "NULL" )
View Source
const ( ColumnDeletedAt = "deleted_at" ColumnId = "id" ColumnName = "name" )
View Source
const ( ExprEqual = " = ?" ExprNotEqual = " != ?" ExprGreater = " > ?" )
View Source
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` )
View Source
const ( NotDeleted = ColumnDeletedAt + " IS " + NullStr WithNotDeleted = ` AND ` + NotDeleted )
View Source
const ( IdEqual = ColumnId + ExprEqual NameEqual = ColumnName + ExprEqual )
View Source
const (
CondiTagName = "sqlcondi" // e.g: `sqlcondi:"column:id;op:="`
)
Variables ¶
This section is empty.
Functions ¶
func ConvertParams ¶ added in v0.3.8
func DeleteByIdSQL ¶ added in v0.3.8
func ExistsByFilterExprsSQL ¶ added in v0.6.0
func ExistsByFilterExprsSQL(tableName string, filters FilterExprs) string
func ExistsByQuerySQL ¶ added in v0.6.0
Types ¶
type ConditionOperation ¶ added in v0.6.0
type ConditionOperation int
const ( OperationPlace ConditionOperation = iota Equal NotEqual Greater Less Between GreaterOrEqual LessOrEqual IsNotNull IsNull In NotIn Like )
func ParseConditionOperation ¶ added in v0.6.0
func ParseConditionOperation(op string) ConditionOperation
func (ConditionOperation) SQL ¶ added in v0.6.0
func (m ConditionOperation) SQL() string
func (ConditionOperation) String ¶ added in v0.6.0
func (m ConditionOperation) String() string
type ConditionTag ¶ added in v0.6.0
type ConditionTag struct { Column string `meta:"column"` Expr string `meta:"expr"` Op string `meta:"op"` EmptyValid bool `meta:"emptyvalid"` }
func GetSQLCondition ¶ added in v0.6.0
func GetSQLCondition(tag reflect.StructTag) (*ConditionTag, error)
type FilterExpr ¶ added in v0.3.8
type FilterExpr struct { Field string `json:"field"` Operation ConditionOperation `json:"op"` Value []any `json:"value"` }
func (*FilterExpr) Build ¶ added in v0.6.0
func (filter *FilterExpr) Build() string
type FilterExprs ¶ added in v0.3.8
type FilterExprs []FilterExpr
func (FilterExprs) Build ¶ added in v0.3.8
func (f FilterExprs) Build() string
func (FilterExprs) BuildSQL ¶ added in v0.3.8
func (f FilterExprs) BuildSQL() (string, []interface{})
Click to show internal directories.
Click to hide internal directories.