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.mjs
CHANGED
|
@@ -1583,8 +1583,14 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1583
1583
|
return data;
|
|
1584
1584
|
})(this.EntityClass);
|
|
1585
1585
|
AssemblerDeserializer((d) => {
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1586
|
+
const wrapped = wrap(d, true);
|
|
1587
|
+
if (wrapped.getPrimaryKey()) {
|
|
1588
|
+
const entity = this.repo.getEntityManager().merge(this.EntityClass, d);
|
|
1589
|
+
return entity;
|
|
1590
|
+
} else {
|
|
1591
|
+
const entity = this.repo.getEntityManager().create(this.EntityClass, d);
|
|
1592
|
+
return entity;
|
|
1593
|
+
}
|
|
1588
1594
|
})(this.EntityClass);
|
|
1589
1595
|
}
|
|
1590
1596
|
}
|
|
@@ -1872,7 +1878,8 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1872
1878
|
* @param opts - Additional options.
|
|
1873
1879
|
*/
|
|
1874
1880
|
async updateOne(id, update, opts) {
|
|
1875
|
-
const
|
|
1881
|
+
const data = "toPOJO" in wrap(update) ? wrap(update).toPOJO() : update;
|
|
1882
|
+
const dateWithClearUndefined = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== void 0));
|
|
1876
1883
|
this.ensureIdIsNotPresent(dateWithClearUndefined);
|
|
1877
1884
|
const entity = await this.getById(id, opts);
|
|
1878
1885
|
wrap(entity).assign(dateWithClearUndefined);
|
|
@@ -1893,12 +1900,14 @@ var MikroOrmQueryService = class extends RelationQueryService {
|
|
|
1893
1900
|
* @param filter - A Filter used to find the records to update
|
|
1894
1901
|
*/
|
|
1895
1902
|
async updateMany(update, filter) {
|
|
1903
|
+
const data = "toPOJO" in wrap(update) ? wrap(update).toPOJO() : update;
|
|
1904
|
+
const dateWithClearUndefined = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== void 0));
|
|
1896
1905
|
this.ensureIdIsNotPresent(update);
|
|
1897
1906
|
const entities = await this.query({
|
|
1898
1907
|
filter
|
|
1899
1908
|
});
|
|
1900
1909
|
for (const entity of entities) {
|
|
1901
|
-
wrap(entity).assign(
|
|
1910
|
+
wrap(entity).assign(dateWithClearUndefined);
|
|
1902
1911
|
}
|
|
1903
1912
|
await this.repo.getEntityManager().flush();
|
|
1904
1913
|
return {
|