聊天:最近私聊历史相关逻辑

This commit is contained in:
liangtongchuan
2021-03-10 12:49:12 +08:00
parent 253efb4966
commit 41025cacf9
5 changed files with 75 additions and 8 deletions
+10
View File
@@ -51,6 +51,16 @@ export default class PrivateMessage extends BaseModel {
const result = await PrivateMessageModel.find({ roomId, seqId: { $lt: fromSeqId } }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
public static async getMsgsByTime(roomId: string, time: Date, count: number) {
const result = await PrivateMessageModel.find({ roomId, createdAt: { $gt: time } }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
public static async getMsgByRooms(roomIds: string[], count: number) {
const result = await PrivateMessageModel.find({ roomId: { $in: roomIds } }).sort({ seqId: -1 }).limit(count).lean();
return result;
}
}