@nextage/nx-frame-be 1.0.6 → 1.0.9
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.
|
@@ -30,8 +30,10 @@ import { ArrayItemParams, BaseMongoDoc } from './base.interfaces';
|
|
|
30
30
|
import { FilterParams, QueryPagination } from './base.interfaces';
|
|
31
31
|
export declare abstract class BaseController<TAttrs, TDoc extends BaseMongoDoc, T extends BaseModel<TAttrs, TDoc, any>> {
|
|
32
32
|
model: T;
|
|
33
|
-
|
|
33
|
+
mergeUpdate: boolean;
|
|
34
|
+
constructor({ model, mergeUpdate }: {
|
|
34
35
|
model: T;
|
|
36
|
+
mergeUpdate?: boolean;
|
|
35
37
|
});
|
|
36
38
|
get collectionName(): string | null;
|
|
37
39
|
/**
|
|
@@ -57,6 +59,12 @@ export declare abstract class BaseController<TAttrs, TDoc extends BaseMongoDoc,
|
|
|
57
59
|
* @returns
|
|
58
60
|
*/
|
|
59
61
|
get(id: string, context?: NxContext): Promise<TDoc | null>;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param item
|
|
65
|
+
* @param context
|
|
66
|
+
*/
|
|
67
|
+
protected parseItem(item: TAttrs, context: NxContext): void;
|
|
60
68
|
/**
|
|
61
69
|
*
|
|
62
70
|
* @param params
|
|
@@ -11,8 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseController = void 0;
|
|
13
13
|
class BaseController {
|
|
14
|
-
constructor({ model }) {
|
|
14
|
+
constructor({ model, mergeUpdate }) {
|
|
15
|
+
this.mergeUpdate = false;
|
|
15
16
|
this.model = model;
|
|
17
|
+
this.mergeUpdate = !!mergeUpdate;
|
|
16
18
|
}
|
|
17
19
|
get collectionName() {
|
|
18
20
|
return this.model.collectionName;
|
|
@@ -50,6 +52,13 @@ class BaseController {
|
|
|
50
52
|
return this.model.get(id, context);
|
|
51
53
|
});
|
|
52
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param item
|
|
58
|
+
* @param context
|
|
59
|
+
*/
|
|
60
|
+
parseItem(item, context) {
|
|
61
|
+
}
|
|
53
62
|
/**
|
|
54
63
|
*
|
|
55
64
|
* @param params
|
|
@@ -66,6 +75,7 @@ class BaseController {
|
|
|
66
75
|
* @returns
|
|
67
76
|
*/
|
|
68
77
|
create(item, context) {
|
|
78
|
+
this.parseItem(item, context);
|
|
69
79
|
return this.model.create(item, context);
|
|
70
80
|
}
|
|
71
81
|
/**
|
|
@@ -76,6 +86,7 @@ class BaseController {
|
|
|
76
86
|
* @returns
|
|
77
87
|
*/
|
|
78
88
|
update(id, item, context) {
|
|
89
|
+
this.parseItem(item, context);
|
|
79
90
|
return this.model.update(id, item, context);
|
|
80
91
|
}
|
|
81
92
|
/**
|
package/build/common/utils.js
CHANGED