nestjs-query-mikro-orm 0.1.1 → 0.1.2
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.cjs +0 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { MikroOrmModule, getRepositoryToken } from '@mikro-orm/nestjs';
|
|
2
|
-
import { getFilterFields, AssemblerFactory,
|
|
2
|
+
import { getFilterFields, AssemblerFactory, getQueryServiceToken } from '@ptc-org/nestjs-query-core';
|
|
3
3
|
import { raw, wrap } from '@mikro-orm/core';
|
|
4
|
-
import { getAssemblerSerializer } from '@ptc-org/nestjs-query-core/src/assemblers/assembler.serializer';
|
|
5
4
|
import { BadRequestException, NotFoundException, MethodNotAllowedException } from '@nestjs/common';
|
|
6
|
-
import { instanceToPlain } from 'class-transformer';
|
|
7
5
|
import merge from 'lodash.merge';
|
|
8
6
|
|
|
9
7
|
var __defProp = Object.defineProperty;
|
|
@@ -1565,28 +1563,6 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1565
1563
|
super(), this.repo = repo;
|
|
1566
1564
|
this.filterQueryBuilder = opts?.filterQueryBuilder ?? new FilterQueryBuilder(this.repo);
|
|
1567
1565
|
this.useSoftDelete = opts?.useSoftDelete ?? false;
|
|
1568
|
-
const serializer = getAssemblerSerializer(this.EntityClass);
|
|
1569
|
-
if (!serializer) {
|
|
1570
|
-
AssemblerSerializer((e) => {
|
|
1571
|
-
const json = instanceToPlain(e, {
|
|
1572
|
-
enableImplicitConversion: true,
|
|
1573
|
-
excludeExtraneousValues: true,
|
|
1574
|
-
exposeDefaultValues: true
|
|
1575
|
-
});
|
|
1576
|
-
const jsonWithRemovedEmptyObjects = Object.fromEntries(Object.entries(json).filter(([, value]) => !(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0)));
|
|
1577
|
-
const wrapped = wrap(e, true);
|
|
1578
|
-
const ormJson = "toObject" in wrapped ? wrapped.toObject() : {};
|
|
1579
|
-
const data = {
|
|
1580
|
-
...ormJson,
|
|
1581
|
-
...jsonWithRemovedEmptyObjects
|
|
1582
|
-
};
|
|
1583
|
-
return data;
|
|
1584
|
-
})(this.EntityClass);
|
|
1585
|
-
AssemblerDeserializer((d) => {
|
|
1586
|
-
const entity = this.repo.getEntityManager().merge(this.EntityClass, d);
|
|
1587
|
-
return entity;
|
|
1588
|
-
})(this.EntityClass);
|
|
1589
|
-
}
|
|
1590
1566
|
}
|
|
1591
1567
|
get EntityClass() {
|
|
1592
1568
|
const em = this.repo.getEntityManager();
|