diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index 8ae026522..4d7d01f80 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -10,13 +10,14 @@ import ( "context" "errors" "fmt" + "math/rand" + "sync" + "github.com/go-redis/redis/v8" "github.com/gogo/protobuf/sortkeys" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - "math/rand" - "sync" //"github.com/garyburd/redigo/redis" "github.com/golang/protobuf/proto" @@ -206,6 +207,13 @@ func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operat return nil } +func (d *DataBases) UpdateOneMsgList(msg *UserChat) error { + ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second) + c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat) + _, err := c.UpdateOne(ctx, bson.M{"uid": msg.UID}, bson.M{"$set": bson.M{"msg": msg.Msg}}) + return err +} + func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) { log.NewInfo(operationID, utils.GetSelfFuncName(), uid, seqList) var hasSeqList []uint32