forked from go-gorm/gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
80 lines (68 loc) · 2.15 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package gen
import (
"database/sql"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gen/field"
)
var _ Condition = Dao(&DO{})
var _ Condition = field.Expr(field.NewField("", "field"))
// Condition query condition
// field.Expr and subquery(Dao) are expect valued
type Condition interface {
clause.Expression
}
type subQuery interface {
UnderlyingDB() *gorm.DB
buildStmt(opts ...stmtOpt) *gorm.Statement
}
// Dao CRUD methods
type Dao interface {
clause.Expression
subQuery
As(alias string) Dao
Not(conds ...Condition) Dao
Or(conds ...Condition) Dao
Select(columns ...field.Expr) Dao
Where(conds ...Condition) Dao
Order(columns ...field.Expr) Dao
Distinct(columns ...field.Expr) Dao
Omit(columns ...field.Expr) Dao
// Joins(cond field.Expr) Dao
Group(columns field.Expr) Dao
Having(conds ...Condition) Dao
Limit(limit int) Dao
Offset(offset int) Dao
Scopes(funcs ...func(Dao) Dao) Dao
// Preload(conds ...field.Expr) Dao
// Attrs(attrs ...interface{}) Dao
// Assign(attrs ...interface{}) Dao
Unscoped() Dao
Create(value interface{}) error
CreateInBatches(value interface{}, batchSize int) error
Save(value interface{}) error
First(dest interface{}, conds ...field.Expr) error
Last(dest interface{}, conds ...field.Expr) error
Take(dest interface{}, conds ...field.Expr) error
Find(dest interface{}, conds ...field.Expr) error
FindInBatches(dest interface{}, batchSize int, fc func(tx Dao, batch int) error) error
FirstOrInit(dest interface{}, conds ...field.Expr) error
FirstOrCreate(dest interface{}, conds ...field.Expr) error
Update(column field.Expr, value interface{}) error
Updates(values interface{}) error
UpdateColumn(column field.Expr, value interface{}) error
UpdateColumns(values interface{}) error
Delete(value interface{}, conds ...field.Expr) error
Count(count *int64) error
Row() *sql.Row
Rows() (*sql.Rows, error)
Scan(dest interface{}) error
Pluck(column field.Expr, dest interface{}) error
ScanRows(rows *sql.Rows, dest interface{}) error
Transaction(fc func(tx Dao) error, opts ...*sql.TxOptions) error
Begin(opts ...*sql.TxOptions) Dao
Commit() Dao
RollBack() Dao
SavePoint(name string) Dao
RollBackTo(name string) Dao
}