From f8938253cec5010f443ce75732cb60e9689bea2f Mon Sep 17 00:00:00 2001 From: Lukas Jorg Date: Tue, 14 Sep 2021 07:16:10 +0200 Subject: [PATCH] Implemented small method to disable association saving --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 12834f30..6172e7ec 100644 --- a/main.go +++ b/main.go @@ -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()