2020-02-02 09:40:44 +03:00
|
|
|
package callbacks
|
|
|
|
|
2020-02-04 03:56:15 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
"github.com/jinzhu/gorm/clause"
|
|
|
|
)
|
2020-02-02 09:40:44 +03:00
|
|
|
|
|
|
|
func Query(db *gorm.DB) {
|
2020-02-04 03:56:15 +03:00
|
|
|
db.Statement.AddClauseIfNotExists(clause.Select{})
|
2020-02-04 04:51:19 +03:00
|
|
|
db.Statement.AddClauseIfNotExists(clause.From{})
|
2020-02-04 03:56:15 +03:00
|
|
|
|
|
|
|
db.Statement.Build("SELECT", "FROM", "WHERE", "GROUP BY", "ORDER BY", "LIMIT", "FOR")
|
|
|
|
result, err := db.DB.ExecContext(db.Context, db.Statement.SQL.String(), db.Statement.Vars...)
|
|
|
|
fmt.Println(err)
|
|
|
|
fmt.Println(result)
|
|
|
|
fmt.Println(db.Statement.SQL.String(), db.Statement.Vars)
|
2020-02-02 09:40:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func Preload(db *gorm.DB) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func AfterQuery(db *gorm.DB) {
|
|
|
|
// after find
|
|
|
|
}
|