How to update the middle table field sort?

type User struct { Id int gorm:"primaryKey;autoIncrement;" json:"Id" Name string json:"name" }

Roles []Rolegorm:"many2many:user_role;" ... } type Role struct { Id int gorm:"primaryKey;autoIncrement;" json:"Id" Name string json:"name" ... }

user := User{Name:"test", Roles:[]Role{ {Name:"角色名称1"}, {Name:"角色名称2"}, }}

user_role table fields (user_id, role_id, sort)

Now only the role of the intermediate table will be updated_ Id and user_ id . How to update the middle table field sort ?