title: golang gorm update associations on save
body: <p>is there a way to automatically remove associations when an object is saved?</p>
  
  <p>something like this:</p>
  
  <pre><code>type Parent struct {
      gorm.Model
      Name string
      Children []*Child
  }
  
  type Child struct {
      gorm.Model
      Name string
      ParentID uint
  }
  
  func myFunc(db *gorm.DB) {
      p := &amp;Parent{Name: "foo", Children:[]*Child{ {Name:"Bar"}, {Name:"Foobar"}}}
      db.Save(&amp;p)
  
      p.Children = p.Children[1:]
      db.Save(&amp;p)  // both children still exist in the database. i'd like the first child to be deleted here
  }
  </code></pre>
  
  <p>`</p>
  
  <p>I've found some tricks with db.Model(&amp;Parent).Association("Children").Clear(), but that just sets the ParentID value to NULL, rather than deleting the record. Is there a simple way of doing this?</p>
  
  <p>Many thanks in advance :)</p>