|
@@ -17,11 +17,10 @@ export class ChatService extends BaseService<modelType> {
|
|
|
// 聊天
|
|
|
async chat(filter) {
|
|
|
const user = this.ctx.user;
|
|
|
- const { skip = 0, limit = 0, ...condition } = filter;
|
|
|
const list = await this.model.aggregate([
|
|
|
{
|
|
|
$match: {
|
|
|
- ...condition,
|
|
|
+ ...filter,
|
|
|
$or: [{ sender_id: get(user, '_id') }, { receiver_id: get(user, '_id') }],
|
|
|
},
|
|
|
},
|
|
@@ -30,9 +29,7 @@ export class ChatService extends BaseService<modelType> {
|
|
|
$replaceRoot: {
|
|
|
newRoot: '$other',
|
|
|
},
|
|
|
- },
|
|
|
- { $skip: parseInt(skip) },
|
|
|
- { $limit: parseInt(limit) },
|
|
|
+ }
|
|
|
]);
|
|
|
const data = [];
|
|
|
for (const val of list) {
|
|
@@ -61,7 +58,6 @@ export class ChatService extends BaseService<modelType> {
|
|
|
})
|
|
|
.skip(skip)
|
|
|
.limit(limit)
|
|
|
- .sort({ send_time: 1 })
|
|
|
.lean();
|
|
|
const data = [];
|
|
|
for (const val of list) {
|