Merge f159d05209d0018e492b9273e508c22a75523331 into 9acaa33324bbcc78239a1c913d4f1292c12177b9
This commit is contained in:
		
						commit
						13a18a218e
					
				
							
								
								
									
										5
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								main.go
									
									
									
									
									
								
							@ -326,6 +326,11 @@ func (s *DB) Count(value interface{}) *DB {
 | 
			
		||||
	return s.NewScope(s.Value).count(value).db
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CountDistinct get how many distinct records for a model
 | 
			
		||||
func (s *DB) CountDistinct(value interface{}, columnName string) *DB {
 | 
			
		||||
	return s.NewScope(s.Value).countDistinct(value, columnName).db
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Related get related associations
 | 
			
		||||
func (s *DB) Related(value interface{}, foreignKeys ...string) *DB {
 | 
			
		||||
	return s.clone().NewScope(s.Value).related(value, foreignKeys...).db
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								scope.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								scope.go
									
									
									
									
									
								
							@ -947,6 +947,13 @@ func (scope *Scope) count(value interface{}) *Scope {
 | 
			
		||||
	return scope
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (scope *Scope) countDistinct(value interface{}, column string) *Scope {
 | 
			
		||||
	scope.Search.Select(fmt.Sprintf("count(%s)", column))
 | 
			
		||||
	scope.Search.countingQuery = true
 | 
			
		||||
	scope.Err(scope.row().Scan(value))
 | 
			
		||||
	return scope
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (scope *Scope) typeName() string {
 | 
			
		||||
	typ := scope.IndirectValue().Type()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user