metal-orm 1.0.104 → 1.0.105
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 +27 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/orm/entity-relations.ts +230 -209
- package/src/orm/entity.ts +3 -1
- package/src/orm/relations/belongs-to.ts +1 -1
- package/src/orm/relations/has-many.ts +2 -2
- package/src/orm/relations/has-one.ts +1 -1
- package/src/orm/relations/many-to-many.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -4902,7 +4902,8 @@ var hideInternal = (obj, keys) => {
|
|
|
4902
4902
|
Object.defineProperty(obj, key, {
|
|
4903
4903
|
value: obj[key],
|
|
4904
4904
|
writable: false,
|
|
4905
|
-
configurable:
|
|
4905
|
+
configurable: true,
|
|
4906
|
+
// Must be configurable for Proxy get trap to work properly
|
|
4906
4907
|
enumerable: false
|
|
4907
4908
|
});
|
|
4908
4909
|
}
|
|
@@ -5065,7 +5066,8 @@ var hideInternal2 = (obj, keys) => {
|
|
|
5065
5066
|
Object.defineProperty(obj, key, {
|
|
5066
5067
|
value: obj[key],
|
|
5067
5068
|
writable: false,
|
|
5068
|
-
configurable:
|
|
5069
|
+
configurable: true,
|
|
5070
|
+
// Must be configurable for Proxy get trap to work properly
|
|
5069
5071
|
enumerable: false
|
|
5070
5072
|
});
|
|
5071
5073
|
}
|
|
@@ -5196,7 +5198,8 @@ var hideInternal3 = (obj, keys) => {
|
|
|
5196
5198
|
Object.defineProperty(obj, key, {
|
|
5197
5199
|
value: obj[key],
|
|
5198
5200
|
writable: false,
|
|
5199
|
-
configurable:
|
|
5201
|
+
configurable: true,
|
|
5202
|
+
// Must be configurable for Proxy get trap to work properly
|
|
5200
5203
|
enumerable: false
|
|
5201
5204
|
});
|
|
5202
5205
|
}
|
|
@@ -5301,7 +5304,8 @@ var hideInternal4 = (obj, keys) => {
|
|
|
5301
5304
|
Object.defineProperty(obj, key, {
|
|
5302
5305
|
value: obj[key],
|
|
5303
5306
|
writable: false,
|
|
5304
|
-
configurable:
|
|
5307
|
+
configurable: true,
|
|
5308
|
+
// Must be configurable for Proxy get trap to work properly
|
|
5305
5309
|
enumerable: false
|
|
5306
5310
|
});
|
|
5307
5311
|
}
|
|
@@ -5819,6 +5823,23 @@ var relationLoaderCache = (meta, relationName, factory) => {
|
|
|
5819
5823
|
var proxifyRelationWrapper = (wrapper) => {
|
|
5820
5824
|
return new Proxy(wrapper, {
|
|
5821
5825
|
get(target, prop, _receiver) {
|
|
5826
|
+
if (prop === "toJSON") {
|
|
5827
|
+
return () => {
|
|
5828
|
+
const wrapperToJSON = target.toJSON;
|
|
5829
|
+
if (typeof wrapperToJSON === "function") {
|
|
5830
|
+
return wrapperToJSON.call(target);
|
|
5831
|
+
}
|
|
5832
|
+
const getRef2 = target.get;
|
|
5833
|
+
if (typeof getRef2 === "function") {
|
|
5834
|
+
return getRef2.call(target);
|
|
5835
|
+
}
|
|
5836
|
+
const getItems2 = target.getItems;
|
|
5837
|
+
if (typeof getItems2 === "function") {
|
|
5838
|
+
return getItems2.call(target);
|
|
5839
|
+
}
|
|
5840
|
+
return target;
|
|
5841
|
+
};
|
|
5842
|
+
}
|
|
5822
5843
|
if (typeof prop === "symbol") {
|
|
5823
5844
|
const value = Reflect.get(target, prop, target);
|
|
5824
5845
|
return typeof value === "function" ? value.bind(target) : value;
|
|
@@ -5993,7 +6014,8 @@ var createEntityProxy = (ctx, table, row, lazyRelations = [], lazyRelationOption
|
|
|
5993
6014
|
const buildJson = (self) => {
|
|
5994
6015
|
const json = {};
|
|
5995
6016
|
for (const key of Object.keys(target)) {
|
|
5996
|
-
|
|
6017
|
+
const value = self[key];
|
|
6018
|
+
json[key] = unwrapRelationForJson(value);
|
|
5997
6019
|
}
|
|
5998
6020
|
for (const [relationName, wrapper] of meta.relationWrappers) {
|
|
5999
6021
|
if (Object.prototype.hasOwnProperty.call(json, relationName)) continue;
|