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)
|
||||
func (db *DB) Scopes(funcs ...func(*DB) *DB) *DB {
|
||||
for _, f := range funcs {
|
||||
db = f(db)
|
||||
}
|
||||
return db
|
||||
func (db *DB) Scopes(funcs ...func(*DB) *DB) (tx *DB) {
|
||||
tx = db.getInstance()
|
||||
tx.Statement.scopes = append(tx.Statement.scopes, funcs...)
|
||||
return tx
|
||||
}
|
||||
|
||||
// Preload preload associations with given conditions
|
||||
|
|
Loading…
Reference in New Issue