Implemented small method to disable association saving

This commit is contained in:
Lukas Jorg 2021-09-14 07:16:10 +02:00 committed by Gerhard Gruber
parent 98d691603d
commit f8938253ce

View File

@ -533,6 +533,11 @@ func (s *DB) WrapInTx(f func(tx *gorm.DB) (error)) error {
return nil
}
// SkipAssocSave disables saving of associations
func (s *DB) SkipAssocSave() *DB {
return s.Set("gorm:save_associations", false)
}
// NewRecord check if value's primary key is blank
func (s *DB) NewRecord(value interface{}) bool {
return s.NewScope(value).PrimaryKeyZero()