nestjs-query-mikro-orm 0.1.1 → 0.1.3
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 +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1589,8 +1589,14 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1589
1589
|
return data;
|
|
1590
1590
|
})(this.EntityClass);
|
|
1591
1591
|
nestjsQueryCore.AssemblerDeserializer((d) => {
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1592
|
+
const wrapped = core.wrap(d, true);
|
|
1593
|
+
if (wrapped.getPrimaryKey()) {
|
|
1594
|
+
const entity = this.repo.getEntityManager().merge(this.EntityClass, d);
|
|
1595
|
+
return entity;
|
|
1596
|
+
} else {
|
|
1597
|
+
const entity = this.repo.getEntityManager().create(this.EntityClass, d);
|
|
1598
|
+
return entity;
|
|
1599
|
+
}
|
|
1594
1600
|
})(this.EntityClass);
|
|
1595
1601
|
}
|
|
1596
1602
|
}
|
|
@@ -1878,7 +1884,8 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1878
1884
|
* @param opts - Additional options.
|
|
1879
1885
|
*/
|
|
1880
1886
|
async updateOne(id, update, opts) {
|
|
1881
|
-
const
|
|
1887
|
+
const data = "toPOJO" in core.wrap(update) ? core.wrap(update).toPOJO() : update;
|
|
1888
|
+
const dateWithClearUndefined = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== void 0));
|
|
1882
1889
|
this.ensureIdIsNotPresent(dateWithClearUndefined);
|
|
1883
1890
|
const entity = await this.getById(id, opts);
|
|
1884
1891
|
core.wrap(entity).assign(dateWithClearUndefined);
|
|
@@ -1899,12 +1906,14 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1899
1906
|
* @param filter - A Filter used to find the records to update
|
|
1900
1907
|
*/
|
|
1901
1908
|
async updateMany(update, filter) {
|
|
1909
|
+
const data = "toPOJO" in core.wrap(update) ? core.wrap(update).toPOJO() : update;
|
|
1910
|
+
const dateWithClearUndefined = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== void 0));
|
|
1902
1911
|
this.ensureIdIsNotPresent(update);
|
|
1903
1912
|
const entities = await this.query({
|
|
1904
1913
|
filter
|
|
1905
1914
|
});
|
|
1906
1915
|
for (const entity of entities) {
|
|
1907
|
-
core.wrap(entity).assign(
|
|
1916
|
+
core.wrap(entity).assign(dateWithClearUndefined);
|
|
1908
1917
|
}
|
|
1909
1918
|
await this.repo.getEntityManager().flush();
|
|
1910
1919
|
return {
|