lrf402788946 4 năm trước cách đây
mục cha
commit
fcad9b096e
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      app/service/chat.js

+ 2 - 2
app/service/chat.js

@@ -14,11 +14,11 @@ class ChatService extends CrudService {
     this.cRoom = this.ctx.model.Room;
   }
 
-  async query({ sendid, receiveid, type }, { skip, limit }) {
+  async query({ sendid, receiveid, type, sort = 1 }, { skip, limit }) {
     assert(sendid, 'sendid不能为空');
     assert(receiveid, 'receiveid不能为空');
     const chatsall = await this.model.find({ $or: [{ sendid, receiveid }, { sendid: receiveid, receiveid: sendid }] });
-    const chats = await this.model.find({ $or: [{ sendid, receiveid }, { sendid: receiveid, receiveid: sendid }] }).sort({ sendtime: -1 }).limit(limit)
+    const chats = await this.model.find({ $or: [{ sendid, receiveid }, { sendid: receiveid, receiveid: sendid }] }).sort({ sendtime: sort }).limit(limit)
       .skip(skip);
     const newchats = [];
     for (const el of chats) {