|
@@ -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 };
|