mirror of https://github.com/go-gorm/gorm.git
Lazy call registered scopes
This commit is contained in:
parent
828e6b646b
commit
6b7d18656d
|
@ -240,11 +240,10 @@ func (db *DB) Offset(offset int) (tx *DB) {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// db.Scopes(AmountGreaterThan1000, OrderStatus([]string{"paid", "shipped"})).Find(&orders)
|
// db.Scopes(AmountGreaterThan1000, OrderStatus([]string{"paid", "shipped"})).Find(&orders)
|
||||||
func (db *DB) Scopes(funcs ...func(*DB) *DB) *DB {
|
func (db *DB) Scopes(funcs ...func(*DB) *DB) (tx *DB) {
|
||||||
for _, f := range funcs {
|
tx = db.getInstance()
|
||||||
db = f(db)
|
tx.Statement.scopes = append(tx.Statement.scopes, funcs...)
|
||||||
}
|
return tx
|
||||||
return db
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preload preload associations with given conditions
|
// Preload preload associations with given conditions
|
||||||
|
|
Loading…
Reference in New Issue