@eeplatform/basic-edu 1.3.6 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4583,7 +4583,7 @@ function useSchoolRepo() {
4583
4583
  deletedAt: { $in: ["", null] },
4584
4584
  status
4585
4585
  };
4586
- sort = Object.keys(sort).length > 0 ? sort : { _id: 1 };
4586
+ sort = Object.keys(sort).length > 0 ? sort : {};
4587
4587
  const cacheKeyOptions = {
4588
4588
  status,
4589
4589
  page,
@@ -4612,12 +4612,12 @@ function useSchoolRepo() {
4612
4612
  });
4613
4613
  return cached;
4614
4614
  }
4615
- const items = await collection.aggregate([
4616
- { $match: query },
4617
- { $sort: sort },
4618
- { $skip: page * limit },
4619
- { $limit: limit }
4620
- ]).toArray();
4615
+ const pipeline = [{ $match: query }];
4616
+ if (Object.keys(sort).length > 0) {
4617
+ pipeline.push({ $sort: sort });
4618
+ }
4619
+ pipeline.push({ $skip: page * limit }, { $limit: limit });
4620
+ const items = await collection.aggregate(pipeline).toArray();
4621
4621
  const length = await collection.countDocuments(query);
4622
4622
  const data = paginate6(items, page, limit, length);
4623
4623
  setCache(cacheKey, data, 600).then(() => {