From cad689b33774713995a315ad878ba65ca6b56f49 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 1 Nov 2022 19:03:54 +0800 Subject: [PATCH] test cron --- pkg/common/db/mongoModel.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/common/db/mongoModel.go b/pkg/common/db/mongoModel.go index d83fae3c3..2164648df 100644 --- a/pkg/common/db/mongoModel.go +++ b/pkg/common/db/mongoModel.go @@ -264,7 +264,7 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat) //regex := fmt.Sprintf("/^%s/", ID) findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"uid": 1}) - var msgs []UserChat + var msgs UserChat // bson.M{"$regex": primitive.Regex{Pattern: regex}} cursor, err := c.Find(ctx, bson.M{"uid": "3729483847:0"}, findOpts) if err != nil { @@ -276,11 +276,12 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er if err != nil { return nil, utils.Wrap(err, fmt.Sprintf("cursor is %s", cursor.Current.String())) } - if len(msgs) > 0 { - return &msgs[0], err - } else { - return nil, errors.New("get msg list failed") - } + //if len(msgs) > 0 { + // return &msgs[0], err + //} else { + // return nil, errors.New("get msg list failed") + //} + return &msgs, nil } func (d *DataBases) DelMongoMsgs(IDList []string) error {