|
@@ -90,13 +90,15 @@ class MongooseHelper {
|
|
|
let self = this;
|
|
|
let limit = 0;
|
|
|
let skip = 0;
|
|
|
+ let sort = {};
|
|
|
if (option !== null && Object.keys(option).length > 0) {
|
|
|
limit = option.pageSize !== undefined ? option.pageSize : limit;
|
|
|
skip = option.offset !== undefined ? option.offset : skip;
|
|
|
+ sort = option.sort !== undefined ? option.sort : sort;
|
|
|
}
|
|
|
conditions = self._convertId(conditions);
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
- self.model.find(conditions, fields).skip(skip).limit(limit)
|
|
|
+ self.model.find(conditions, fields).skip(skip).limit(limit).sort(sort)
|
|
|
.populate(populate).exec(function(error, data) {
|
|
|
if (error) {
|
|
|
reject(error);
|