Documentation ¶
Index ¶
- func BulkExec(db *gorm.DB, objects []interface{}, execFunc ExecFunc) error
- func BulkExecChunk(db *gorm.DB, objects []interface{}, execFunc ExecFunc, chunkSize int) []error
- func BulkInsert(db *gorm.DB, objects []interface{}) error
- func BulkInsertIgnore(db *gorm.DB, objects []interface{}) error
- func BulkInsertOnDuplicateKeyUpdate(db *gorm.DB, objects []interface{}) error
- func InsertFunc(scope *gorm.Scope, columnNames, groups []string)
- func InsertIgnoreFunc(scope *gorm.Scope, columnNames, groups []string)
- func InsertOnDuplicateKeyUpdateFunc(scope *gorm.Scope, columnNames, groups []string)
- func ObjectToMap(object interface{}) (map[string]*gorm.Field, error)
- type ExecFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BulkExec ¶
BulkExec will convert a slice of interface to bulk SQL statement. The final SQL will be determined by the ExecFunc passed.
func BulkExecChunk ¶
BulkExecChunk will split the objects passed into the passed chunk size. A slice of errors will be returned (if any).
func BulkInsert ¶
BulkInsert will call BulkExec with the default InsertFunc.
func BulkInsertIgnore ¶
BulkInsertIgnore will call BulkExec with the default InsertFunc.
func BulkInsertOnDuplicateKeyUpdate ¶
BulkInsertOnDuplicateKeyUpdate will call BulkExec with the default InsertFunc.
func InsertFunc ¶
InsertFunc is the default insert func. It will pass a gorm.Scope pointer which holds all the vars in scope.SQLVars. The value set to scope.SQL will be used as SQL and the variables in scope.SQLVars will be used as values.
INSERT INTO `tbl` (col1, col2) VALUES (?, ?), (?, ?)
func InsertIgnoreFunc ¶
InsertIgnoreFunc will run INSERT IGNORE with all the records and values set on the passed scope pointer.
INSERT IGNORE INTO `tbl` (col1, col2) VALUES (?, ?), (?, ?)
func InsertOnDuplicateKeyUpdateFunc ¶
InsertOnDuplicateKeyUpdateFunc will perform a bulk insert but on duplicate key perform an update.
INSERT INTO `tbl` (col1, col2) VALUES (?, ?), (?, ?) ON DUPLICATE KEY UPDATE col1 = VALUES(col1), col2 = VALUES(col2)
func ObjectToMap ¶
ObjectToMap takes any object of type <T> and returns a map with the gorm field DB name as key and the value as value. Special fields and actions
- Foreign keys - Will be left out
- Relationship fields - Will be left out
- Fields marked to be ignored - Will be left out
- Fields named ID with auto increment - Will be left out
- Fields named ID set as primary key with blank value - Will be left out
- Blank fields with default value - Will be set to the default value
Types ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Code generated by slice-converter; DO NOT EDIT.
|
Code generated by slice-converter; DO NOT EDIT. |