Merge pull request #897 from jinzhu/pedromorgan-patch-1
Explain chaining a bit more
This commit is contained in:
		
						commit
						c79acf4293
					
				@ -12,8 +12,15 @@ db, err := gorm.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
 | 
			
		||||
// create a new relation
 | 
			
		||||
db = db.Where("name = ?", "jinzhu")
 | 
			
		||||
 | 
			
		||||
// create another new relation
 | 
			
		||||
// filter even more
 | 
			
		||||
if SomeCondition {
 | 
			
		||||
    db = db.Where("age = ?", 20)
 | 
			
		||||
} else {
 | 
			
		||||
    db = db.Where("age = ?", 30)
 | 
			
		||||
}
 | 
			
		||||
if YetAnotherCondition {
 | 
			
		||||
    db = db.Where("active = ?", 1)
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
When we start to perform any operations, GROM will create a new `*gorm.Scope` instance based on current `*gorm.DB`
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user