func updateConnections(view db.Database, spec stitch.Stitch) { scs, vcs := stitch.ConnectionSlice(spec.Connections), view.SelectFromConnection(nil) dbcKey := func(val interface{}) interface{} { c := val.(db.Connection) return stitch.Connection{ From: c.From, To: c.To, MinPort: c.MinPort, MaxPort: c.MaxPort, } } pairs, stitches, dbcs := join.HashJoin(scs, db.ConnectionSlice(vcs), nil, dbcKey) for _, dbc := range dbcs { view.Remove(dbc.(db.Connection)) } for _, stitchc := range stitches { pairs = append(pairs, join.Pair{L: stitchc, R: view.InsertConnection()}) } for _, pair := range pairs { stitchc := pair.L.(stitch.Connection) dbc := pair.R.(db.Connection) dbc.From = stitchc.From dbc.To = stitchc.To dbc.MinPort = stitchc.MinPort dbc.MaxPort = stitchc.MaxPort view.Commit(dbc) } }