GetMsgBySeqIndexIn1Doc

This commit is contained in:
wangchuxiao 2023-05-11 20:12:34 +08:00
parent 945b638d4d
commit 1dab783299

View File

@ -137,13 +137,13 @@ func (m *MsgMongoDriver) UpdateOneDoc(ctx context.Context, msg *table.MsgDocMode
func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, docID string, beginSeq, endSeq int64) (msgs []*sdkws.MsgData, seqs []int64, err error) { func (m *MsgMongoDriver) GetMsgBySeqIndexIn1Doc(ctx context.Context, docID string, beginSeq, endSeq int64) (msgs []*sdkws.MsgData, seqs []int64, err error) {
beginIndex := m.msg.GetMsgIndex(beginSeq) beginIndex := m.msg.GetMsgIndex(beginSeq)
num := endSeq - beginSeq + 1 num := endSeq - beginSeq + 1
log.ZDebug(ctx, "beginIndex", beginIndex, "num", num)
pipeline := bson.A{ pipeline := bson.A{
bson.M{ bson.M{
"$match": bson.M{"doc_id": docID}, "$match": bson.M{"doc_id": docID},
}, },
bson.M{ bson.M{
"$project": bson.M{ "$project": bson.M{
"doc_id": 1,
"msgs": bson.M{ "msgs": bson.M{
"$slice": []interface{}{"$msgs", beginIndex, num}, "$slice": []interface{}{"$msgs", beginIndex, num},
}, },