| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package db_operations
- type DBOperations interface {
- BeginTransaction() TransactionDBOperations
- BaseDBOperations
- }
- type TransactionDBOperations interface {
- BaseDBOperations
- RollbackTransaction()
- CommitTransaction()
- }
- type BaseDBOperations interface {
- // 会重置数据库连接的方法
- NewSession() DBOperations
- Table(name string, args ...any) DBOperations
- // 执行SQL语句,使用Raw之后必须使用Rows或Row,否则不执行SQL
- Raw(sql string, values ...any) DBOperations
- // 组织SQL语句相关的方法
- Select(query string, args ...any) DBOperations
- Where(query string, args ...any) DBOperations
- Or(query string, args ...any) DBOperations
- GroupBy(groupBy string) DBOperations
- OrderBy(orderBy string) DBOperations
- Joins(query string, args ...any) DBOperations
- Having(query string, args ...any) DBOperations
- Paging(pageNo int, pageSize int) DBOperations
- // 写方法
- Create(tableRow map[string]any) error
- CreateBatch(tableRows []map[string]any) error
- Delete() error
- Updates(updateData map[string]any) error
- UpdatesWithRowsAffected(updateData map[string]any) (int64, error)
- // 查询方法
- Rows(pageNo int, pageSize int) ([]map[string]any, error)
- Row() (map[string]any, error)
- // 其他方法
- Count(count *int64) error
- }
|