大攀の小窝

路在脚下,心向远方

开发过程积累

过程记录

Go开发

gorm on duplicate用法

gorm on duplicate

friend := models.Friend{ GameId: p.gameID, Uid: uid, UNick: uNick, UAvatar: uAvatar, Fid: fid, FNick: fNick, FAvatar: fAvatar, CreateTime: time.Now().Unix(), } err := mysql.MysqlClient.Table(p.tableName).Where("game_id = ? and uid = ? and fid = ?", p.gameID, uid, fid).Assign(models.Friend{CreateTime: time.Now().Unix()}).FirstOrCreate(&friend).Error