@nextage/nx-frame-be 1.0.26 → 1.0.29

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.
@@ -152,6 +152,13 @@ export declare class BaseModel<TAttrs, TDoc extends BaseMongoDoc, TMongoModel ex
152
152
  * @param {*} params
153
153
  */
154
154
  findOneNative(params: FilterParams): Promise<mongoose.mongo.WithId<mongoose.mongo.BSON.Document> | null>;
155
+ /**
156
+ *
157
+ * @param id
158
+ * @param context
159
+ * @returns
160
+ */
161
+ beforeGet(filter: FilterParams, context: NxContext): Promise<FilterParams>;
155
162
  /**
156
163
  *
157
164
  * @param {*} item
@@ -197,8 +197,10 @@ class BaseModel extends events_1.EventEmitter {
197
197
  get(id_1) {
198
198
  return __awaiter(this, arguments, void 0, function* (id, context = {}) {
199
199
  if (!id)
200
- return Promise.resolve(null);
201
- return this.mgModel.findById(id);
200
+ return null;
201
+ const filter = { _id: (0, mongo_utils_1.toObjectId)(id) };
202
+ yield this.beforeGet(filter, context);
203
+ return this.mgModel.findOne(filter);
202
204
  });
203
205
  }
204
206
  /**
@@ -247,6 +249,17 @@ class BaseModel extends events_1.EventEmitter {
247
249
  findOneNative(params) {
248
250
  return this.mgModel.collection.findOne(params);
249
251
  }
252
+ /**
253
+ *
254
+ * @param id
255
+ * @param context
256
+ * @returns
257
+ */
258
+ beforeGet(filter, context) {
259
+ return __awaiter(this, void 0, void 0, function* () {
260
+ return filter;
261
+ });
262
+ }
250
263
  /**
251
264
  *
252
265
  * @param {*} item
@@ -432,7 +445,7 @@ class BaseModel extends events_1.EventEmitter {
432
445
  item = yield this.beforeUpdate(item, context);
433
446
  //const res = await this.mgModel.findByIdAndUpdate(id, { $set: item }, { new: true });
434
447
  //const itemDoc = this.mgModel.build(Object.assign({ id, item }));
435
- const itemDoc = yield this.get(id);
448
+ const itemDoc = yield this.get(id, context);
436
449
  if (!itemDoc)
437
450
  throw new errors_1.AppError('messages.notFound');
438
451
  // complete merge
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextage/nx-frame-be",
3
- "version": "1.0.26",
3
+ "version": "1.0.29",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",