Explain chaining a bit more
This commit is contained in:
		
							parent
							
								
									46e2a98e8d
								
							
						
					
					
						commit
						b6d8e1c101
					
				@ -12,8 +12,15 @@ db, err := gorm.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
 | 
				
			|||||||
// create a new relation
 | 
					// create a new relation
 | 
				
			||||||
db = db.Where("name = ?", "jinzhu")
 | 
					db = db.Where("name = ?", "jinzhu")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// create another new relation
 | 
					// filter even more
 | 
				
			||||||
 | 
					if SomeCondition {
 | 
				
			||||||
    db = db.Where("age = ?", 20)
 | 
					    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`
 | 
					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