mongodb-dynamic-api 2.3.6 → 2.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
|
|
3
|
+
## [2.3.7](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.6...v2.3.7) (2024-05-08)
|
|
4
|
+
|
|
3
5
|
## [2.3.6](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.5...v2.3.6) (2024-05-08)
|
|
4
6
|
|
|
5
7
|
## [2.3.5](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.3.3...v2.3.5) (2024-05-08)
|
package/package.json
CHANGED
|
@@ -5,24 +5,24 @@ const mongoose_1 = require("@nestjs/mongoose");
|
|
|
5
5
|
const decorators_1 = require("../decorators");
|
|
6
6
|
const interfaces_1 = require("../interfaces");
|
|
7
7
|
function buildSchemaFromEntity(entity) {
|
|
8
|
-
const
|
|
8
|
+
const schemaOptions = Reflect.getOwnMetadata(decorators_1.DYNAMIC_API_SCHEMA_OPTIONS_METADATA, entity);
|
|
9
9
|
const schema = mongoose_1.SchemaFactory.createForClass(entity);
|
|
10
10
|
schema.set('timestamps', Object.getOwnPropertyNames(schema.paths).includes('createdAt') &&
|
|
11
11
|
Object.getOwnPropertyNames(schema.paths).includes('updatedAt'));
|
|
12
|
-
if (indexes) {
|
|
13
|
-
indexes.forEach(({ fields, options }) => {
|
|
12
|
+
if (schemaOptions?.indexes) {
|
|
13
|
+
schemaOptions.indexes.forEach(({ fields, options }) => {
|
|
14
14
|
schema.index(fields, options);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
if (hooks?.length) {
|
|
17
|
+
if (schemaOptions?.hooks?.length) {
|
|
18
18
|
const isSoftDeletable = Object.getOwnPropertyNames(schema.paths).includes('deletedAt');
|
|
19
|
-
hooks.forEach(({ type, method, callback, options }) => {
|
|
19
|
+
schemaOptions.hooks.forEach(({ type, method, callback, options }) => {
|
|
20
20
|
const { query, softDeletableQuery } = interfaces_1.queryByRouteTypeMap.get(type);
|
|
21
21
|
schema[method](isSoftDeletable && softDeletableQuery ? softDeletableQuery : query, { document: true, query: true, ...options }, callback);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
if (customInit) {
|
|
25
|
-
customInit(schema);
|
|
24
|
+
if (schemaOptions?.customInit) {
|
|
25
|
+
schemaOptions.customInit(schema);
|
|
26
26
|
}
|
|
27
27
|
return schema;
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.helper.js","sourceRoot":"","sources":["../../../libs/dynamic-api/src/helpers/schema.helper.ts"],"names":[],"mappings":";;;AACA,+CAAiD;AAEjD,8CAAoE;AACpE,8CAAsF;AAQtF,SAAS,qBAAqB,CAC5B,MAAoB;IAEpB,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.helper.js","sourceRoot":"","sources":["../../../libs/dynamic-api/src/helpers/schema.helper.ts"],"names":[],"mappings":";;;AACA,+CAAiD;AAEjD,8CAAoE;AACpE,8CAAsF;AAQtF,SAAS,qBAAqB,CAC5B,MAAoB;IAEpB,MAAM,aAAa,GAAG,OAAO,CAAC,cAAc,CAC1C,gDAAmC,EACnC,MAAM,CAC6B,CAAC;IAEtC,MAAM,MAAM,GAAG,wBAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAEpD,MAAM,CAAC,GAAG,CACR,YAAY,EACZ,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC9D,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC/D,CAAC;IAEF,IAAI,aAAa,EAAE,OAAO,EAAE,CAAC;QAC3B,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,E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