Explorar o código

查询聊天记录顺序

zs hai 1 ano
pai
achega
8a6718c57b
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/service/chat.service.ts

+ 1 - 1
src/service/chat.service.ts

@@ -25,7 +25,7 @@ export class ChatService extends BaseService<modelType> {
 
 
   async query(filter: SearchBase, pageOptions: PageOptions = {}): Promise<Array<any>> {
   async query(filter: SearchBase, pageOptions: PageOptions = {}): Promise<Array<any>> {
     const dup = cloneDeep(filter.getFilter());
     const dup = cloneDeep(filter.getFilter());
-    const data = await this.model.find(dup, {}, { ...pageOptions }).populate('speaker');
+    const data = await this.model.find(dup, {}, { ...pageOptions, sort: { 'meta.createdAt': -1 } }).populate('speaker');
     return data;
     return data;
   }
   }