Explorar o código

修改查询bug:skip为0不能进行分页

lrf %!s(int64=3) %!d(string=hai) anos
pai
achega
76afea655e
Modificáronse 2 ficheiros con 5 adicións e 2 borrados
  1. 3 0
      README.zh_CN.md
  2. 2 2
      lib/service/crud-service.js

+ 3 - 0
README.zh_CN.md

@@ -2,7 +2,10 @@
 #### model配置中 
 >```const schema = new Schema(user, { 'multi-tenancy': true, toJSON: { virtuals: true } });```
 
+## 中间件说明
 
+### password
+针对以 非login结尾 的 POST 方法的路由,且 request.headers 中 没有 passwordNoDeal 或 passwordNoDeal 为 false 的请求中. 将 body中的password字段 修改为 {secret:password}的形式
 
 
 # npm 发布相关

+ 2 - 2
lib/service/crud-service.js

@@ -50,13 +50,13 @@ class CrudService extends NafService {
     if (sort && isString(sort)) {
       sort = { [sort]: desc ? -1 : 1 };
     } else if (sort && isArray(sort)) {
-      sort = sort.map((f) => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
+      sort = sort.map(f => ({ [f]: desc ? -1 : 1 })).reduce((p, c) => ({ ...p, ...c }), {});
     }
 
     return await this.model.findOne(filter, projection).exec();
   }
 
-  async query(filter, { skip, limit, sort, desc, projection } = {}) {
+  async query(filter, { skip = 0, limit, sort, desc, projection } = {}) {
     // 处理排序
     if (sort && isString(sort)) {
       sort = { [sort]: desc ? -1 : 1 };