[feat] 统一 orm 入口

This commit is contained in:
2024-05-07 10:15:55 +08:00
parent 14b6334887
commit 6b87809781
4 changed files with 32 additions and 41 deletions
+28
View File
@@ -184,3 +184,31 @@ type QueryWithRecursive interface {
ToQueryBuilder(*db.Builder, Model) (*db.Builder, any)
ToTreeData(any) any
}
// @title 创建关联模型
// @param t 关联类型
// @param m 关联模型
// @param rResource 链接父模型
// @param rField 连接父模型字段, 如 xx_id
// @param rForeignKey 关联外键, 如 id
type NewOrmRelation func(t RelationType, m Model, rResource, rField, rForeignKey string) Model
type NewOrmJoin func(t RelationType, res Resource, alias, rResource, rField, rForeignKey string) Join
type NewOrmCondition func(typ ConditionType, describe string) Condition
type NewOrmConditionExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool) ConditionExpr
type NewOrmConditionFuncExpr func(rResource, rField, token string, operator ConditionOperator, tType ConditionTokenType, ignoreEmptyParma bool, fn, fnParam string) ConditionExpr
type NewOrmQueryWithRecursive func(pField, cField string, root any, isWithoutCondition bool, depth int) QueryWithRecursive
type NewOrmOrderBy func(sql string, direction OrderByDirection) OrderBy
type NewOrmGroupBy func(sql string) GroupBy
type NewOrmModel func(res Resource, code, name string) Model
type NewOrm func(res Resource, tx *db.Transaction) Orm
type GetOrmConditionByRes func(categoryUuid string, describe string) Condition