Add GORM Config
This commit is contained in:
		
							parent
							
								
									becd777b1e
								
							
						
					
					
						commit
						5c485a3e1c
					
				
							
								
								
									
										16
									
								
								gorm.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								gorm.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
package gorm
 | 
			
		||||
 | 
			
		||||
import "github.com/jinzhu/gorm/logger"
 | 
			
		||||
 | 
			
		||||
// Config GORM config
 | 
			
		||||
type Config struct {
 | 
			
		||||
	// SingularTable use singular table name, by default, GORM will pluralize your struct's name as table name
 | 
			
		||||
	// Refer https://github.com/jinzhu/inflection for inflection rules
 | 
			
		||||
	SingularTable bool
 | 
			
		||||
 | 
			
		||||
	// BlockGlobalUpdate generates an error on update/delete without where clause, this is to prevent eventual error with empty objects updates/deletions
 | 
			
		||||
	BlockGlobalUpdate bool
 | 
			
		||||
 | 
			
		||||
	Logger  logger.Interface
 | 
			
		||||
	LogMode logger.LogMode
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								main.go
									
									
									
									
									
								
							@ -143,24 +143,6 @@ func (s *DB) LogMode(enable bool) *DB {
 | 
			
		||||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BlockGlobalUpdate if true, generates an error on update/delete without where clause.
 | 
			
		||||
// This is to prevent eventual error with empty objects updates/deletions
 | 
			
		||||
func (s *DB) BlockGlobalUpdate(enable bool) *DB {
 | 
			
		||||
	s.blockGlobalUpdate = enable
 | 
			
		||||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HasBlockGlobalUpdate return state of block
 | 
			
		||||
func (s *DB) HasBlockGlobalUpdate() bool {
 | 
			
		||||
	return s.blockGlobalUpdate
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SingularTable use singular table by default
 | 
			
		||||
func (s *DB) SingularTable(enable bool) {
 | 
			
		||||
	modelStructsMap = newModelStructsMap()
 | 
			
		||||
	s.parent.singularTable = enable
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewScope create a scope for current operation
 | 
			
		||||
func (s *DB) NewScope(value interface{}) *Scope {
 | 
			
		||||
	dbClone := s.clone()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user