@vasrefil/api-toolkit 1.0.56 → 1.0.58

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.
@@ -15,6 +15,7 @@ export declare class RootController {
15
15
  fetchAllWithPagination: (conditon: object, query?: FetchAllQuery, select?: string | object, populate?: ModelPopulateI[]) => Promise<FetchWithPaginationDataI>;
16
16
  getOneP: (condition: object, select?: any) => Promise<any>;
17
17
  getOne(condition: any, select?: any, populate?: any): import("mongoose").Query<any, any, {}, any>;
18
+ getOneSes(condition: any, session: ClientSession, select?: any, populate?: any): import("mongoose").Query<any, any, {}, any>;
18
19
  getOnePSes: (condition: object, session: ClientSession, select?: string) => Promise<any>;
19
20
  getById: (id: string, select?: string | object) => Promise<any>;
20
21
  getByIdSes: (id: string, session: ClientSession, select?: object | string) => Promise<any>;
@@ -152,6 +152,14 @@ class RootController {
152
152
  }
153
153
  return (this.model.findOne(cond).select(select).populate(populate).lean());
154
154
  }
155
+ getOneSes(condition, session, select, populate) {
156
+ select = select ? select : '';
157
+ let cond = condition;
158
+ if (this.modelName === 'User') {
159
+ cond = { is_deleted: false, ...condition };
160
+ }
161
+ return (this.model.findOne(cond).select(select).populate(populate).session(session).lean());
162
+ }
155
163
  updateOne(condition, updateValues) {
156
164
  return this.model.updateOne({ ...condition }, { ...updateValues }, { new: true });
157
165
  }
@@ -65,9 +65,9 @@ class QueryHelper_ {
65
65
  let range = filterRange ? this.str_to_obj(filterRange) : null;
66
66
  const filterx = filter ? this.str_to_obj(filter) : {};
67
67
  const date_rangex = date_range ? this.str_to_obj(date_range) : {};
68
- const pagex = page ? Number(page) : 1;
69
- const skipx = page ? ((Number(page) - 1) * limit) : 0;
70
68
  const limitx = Number(limit) || 20;
69
+ const pagex = page ? Number(page) : 1;
70
+ const skip = page ? ((Number(pagex) - 1) * limitx) : 0;
71
71
  if (range) {
72
72
  const { field, ranges: { from, to } } = range;
73
73
  range = { [field]: { $gte: from, $lt: to } };
@@ -78,7 +78,7 @@ class QueryHelper_ {
78
78
  const filters = this.process_filters(query);
79
79
  const sort = this.get_sort(query);
80
80
  const filter_result = { ...filterResult, ...date_range_, ...search, ...filters };
81
- return { sort, limit: limitx, filter: filter_result, skip: skipx, page: pagex };
81
+ return { sort, limit: limitx, filter: filter_result, skip, page: pagex };
82
82
  }
83
83
  get_date_range(payload) {
84
84
  let date_filter_range = null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vasrefil/api-toolkit",
3
3
  "description": "This is Vasrefil API toolkit",
4
- "version": "1.0.56",
4
+ "version": "1.0.58",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",