sqlorm

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WhereIs = iota
	WhereNot
	WhereGt
	WhereLt
	WhereOr
	OrderAsc
	OrderDesc
	WhereGte
	WhereLte
)

Variables

This section is empty.

Functions

func GetTableName added in v0.3.6

func GetTableName(dest any) string

获取表名

Types

type Cursor added in v0.3.9

type Cursor struct {
	*sql.Rows
	// contains filtered or unexported fields
}

func (*Cursor) Decode added in v0.3.9

func (c *Cursor) Decode(v any) error

type DBConn

type DBConn struct {
	*gorm.DB
	AutoMigrate bool
	// contains filtered or unexported fields
}
var ORMConn *DBConn

func (*DBConn) Model

func (m *DBConn) Model(data any) types.ORMModel

type Model

type Model struct {
	Data   any
	OpList sync.Map // key:操作模式Mode value:操作值

	Ctx   context.Context //上下文
	Table string
	// contains filtered or unexported fields
}

func (*Model) All added in v0.3.9

func (q *Model) All(data any) error

func (*Model) Asc

func (m *Model) Asc(condition any) types.ORMModel

正序

func (*Model) BulkWrite added in v0.1.9

func (m *Model) BulkWrite(datas any, order bool) error

**

operations := []BulkWriteOperation{
    {
        Type: "insert",
        Data: &User{Name: "Alice"},
    },
    {
        Type:  "update",
        Data:  &User{},
        Where: map[string]any{"name": "Bob"},
        Values: map[string]any{"age": 30},
    },
    {
        Type:  "delete",
        Data:  &User{},
        Where: map[string]any{"name": "Charlie"},
    },
}

err := model.BulkWrite(operations, true) **

func (*Model) Commit added in v0.3.7

func (s *Model) Commit() error

func (*Model) Count added in v0.3.9

func (q *Model) Count() int64

func (*Model) Create

func (m *Model) Create(data any) (id string, err error)

插入数据

func (*Model) Cursor added in v0.3.9

func (q *Model) Cursor() (types.Cursor, error)

func (*Model) Delete

func (m *Model) Delete(data ...any) error

删除

func (*Model) Desc

func (m *Model) Desc(condition any) types.ORMModel

逆序

func (*Model) Find

func (m *Model) Find() types.ORMQuary

查询数据

func (*Model) GetContext added in v0.0.4

func (m *Model) GetContext() context.Context

func (*Model) Insert added in v0.4.0

func (m *Model) Insert(data any) (err error)

func (*Model) Limit

func (m *Model) Limit(limit int) types.ORMModel

限制查询的数量

func (*Model) Offset

func (m *Model) Offset(offset int) types.ORMModel

跳过查询的数量

func (*Model) One added in v0.3.9

func (q *Model) One(data any) error

func (*Model) Page

func (m *Model) Page(page, limit int) types.ORMModel

func (*Model) Rollback added in v0.3.7

func (s *Model) Rollback() error

func (*Model) Save

func (m *Model) Save(data any, value ...any) (err error)

更新或插入数据

func (*Model) Session added in v0.0.4

func (m *Model) Session(transactionFunc func(types.Session) error) error

func (*Model) SetContext added in v0.0.4

func (m *Model) SetContext(ctx context.Context) types.ORMModel

func (*Model) Update

func (m *Model) Update(data any, value ...any) error

修改

func (*Model) Upsert added in v0.4.0

func (m *Model) Upsert(data any, value ...any) error

func (*Model) Where

func (m *Model) Where(condition any, value ...any) types.ORMModel

限制条件

func (*Model) WhereGt

func (m *Model) WhereGt(condition any, value ...any) types.ORMModel

func (*Model) WhereGte added in v0.1.1

func (m *Model) WhereGte(condition any, value ...any) types.ORMModel

func (*Model) WhereIs

func (m *Model) WhereIs(key string, value any) types.ORMModel

func (*Model) WhereLt

func (m *Model) WhereLt(condition any, value ...any) types.ORMModel

func (*Model) WhereLte added in v0.1.1

func (m *Model) WhereLte(condition any, value ...any) types.ORMModel

func (*Model) WhereNot

func (m *Model) WhereNot(condition any, value ...any) types.ORMModel

func (*Model) WhereOr

func (m *Model) WhereOr(condition any, value ...any) types.ORMModel

type Quary

type Quary struct {
	OpList *sync.Map
	// contains filtered or unexported fields
}

func (*Quary) All

func (q *Quary) All(data any) error

func (*Quary) Count

func (q *Quary) Count() int64

func (*Quary) Cursor added in v0.3.9

func (q *Quary) Cursor() (types.Cursor, error)

gorm不支持游标,使用原始SQL实现

func (*Quary) Delete added in v0.0.4

func (q *Quary) Delete() error

func (*Quary) One

func (q *Quary) One(data any) error

type Table added in v0.3.6

type Table interface {
	TableName() string
}

Jump to

Keyboard shortcuts

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