metal-orm 1.0.106 → 1.0.107
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 +54 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/orm/entity.ts +155 -151
- package/src/orm/relations/belongs-to.ts +139 -126
- package/src/orm/relations/has-many.ts +199 -186
- package/src/orm/relations/has-one.ts +171 -158
- package/src/orm/relations/many-to-many.ts +237 -224
package/dist/index.js
CHANGED
|
@@ -4907,6 +4907,17 @@ var hideInternal = (obj, keys) => {
|
|
|
4907
4907
|
});
|
|
4908
4908
|
}
|
|
4909
4909
|
};
|
|
4910
|
+
var hideWritable = (obj, keys) => {
|
|
4911
|
+
for (const key of keys) {
|
|
4912
|
+
const value = obj[key];
|
|
4913
|
+
Object.defineProperty(obj, key, {
|
|
4914
|
+
value,
|
|
4915
|
+
writable: true,
|
|
4916
|
+
configurable: true,
|
|
4917
|
+
enumerable: false
|
|
4918
|
+
});
|
|
4919
|
+
}
|
|
4920
|
+
};
|
|
4910
4921
|
var DefaultHasManyCollection = class {
|
|
4911
4922
|
/**
|
|
4912
4923
|
* Creates a new DefaultHasManyCollection instance.
|
|
@@ -4931,6 +4942,7 @@ var DefaultHasManyCollection = class {
|
|
|
4931
4942
|
this.createEntity = createEntity;
|
|
4932
4943
|
this.localKey = localKey;
|
|
4933
4944
|
hideInternal(this, ["ctx", "meta", "root", "relationName", "relation", "rootTable", "loader", "createEntity", "localKey"]);
|
|
4945
|
+
hideWritable(this, ["loaded", "items", "added", "removed"]);
|
|
4934
4946
|
this.hydrateFromCache();
|
|
4935
4947
|
}
|
|
4936
4948
|
loaded = false;
|
|
@@ -5067,6 +5079,17 @@ var hideInternal2 = (obj, keys) => {
|
|
|
5067
5079
|
});
|
|
5068
5080
|
}
|
|
5069
5081
|
};
|
|
5082
|
+
var hideWritable2 = (obj, keys) => {
|
|
5083
|
+
for (const key of keys) {
|
|
5084
|
+
const value = obj[key];
|
|
5085
|
+
Object.defineProperty(obj, key, {
|
|
5086
|
+
value,
|
|
5087
|
+
writable: true,
|
|
5088
|
+
configurable: true,
|
|
5089
|
+
enumerable: false
|
|
5090
|
+
});
|
|
5091
|
+
}
|
|
5092
|
+
};
|
|
5070
5093
|
var DefaultHasOneReference = class {
|
|
5071
5094
|
/**
|
|
5072
5095
|
* @param ctx The entity context for tracking changes.
|
|
@@ -5100,6 +5123,7 @@ var DefaultHasOneReference = class {
|
|
|
5100
5123
|
"createEntity",
|
|
5101
5124
|
"localKey"
|
|
5102
5125
|
]);
|
|
5126
|
+
hideWritable2(this, ["loaded", "current"]);
|
|
5103
5127
|
this.populateFromHydrationCache();
|
|
5104
5128
|
}
|
|
5105
5129
|
loaded = false;
|
|
@@ -5195,6 +5219,17 @@ var hideInternal3 = (obj, keys) => {
|
|
|
5195
5219
|
});
|
|
5196
5220
|
}
|
|
5197
5221
|
};
|
|
5222
|
+
var hideWritable3 = (obj, keys) => {
|
|
5223
|
+
for (const key of keys) {
|
|
5224
|
+
const value = obj[key];
|
|
5225
|
+
Object.defineProperty(obj, key, {
|
|
5226
|
+
value,
|
|
5227
|
+
writable: true,
|
|
5228
|
+
configurable: true,
|
|
5229
|
+
enumerable: false
|
|
5230
|
+
});
|
|
5231
|
+
}
|
|
5232
|
+
};
|
|
5198
5233
|
var DefaultBelongsToReference = class {
|
|
5199
5234
|
/**
|
|
5200
5235
|
* @param ctx The entity context for tracking changes.
|
|
@@ -5218,6 +5253,7 @@ var DefaultBelongsToReference = class {
|
|
|
5218
5253
|
this.createEntity = createEntity;
|
|
5219
5254
|
this.targetKey = targetKey;
|
|
5220
5255
|
hideInternal3(this, ["ctx", "meta", "root", "relationName", "relation", "rootTable", "loader", "createEntity", "targetKey"]);
|
|
5256
|
+
hideWritable3(this, ["loaded", "current"]);
|
|
5221
5257
|
this.populateFromHydrationCache();
|
|
5222
5258
|
}
|
|
5223
5259
|
loaded = false;
|
|
@@ -5297,6 +5333,17 @@ var hideInternal4 = (obj, keys) => {
|
|
|
5297
5333
|
});
|
|
5298
5334
|
}
|
|
5299
5335
|
};
|
|
5336
|
+
var hideWritable4 = (obj, keys) => {
|
|
5337
|
+
for (const key of keys) {
|
|
5338
|
+
const value = obj[key];
|
|
5339
|
+
Object.defineProperty(obj, key, {
|
|
5340
|
+
value,
|
|
5341
|
+
writable: true,
|
|
5342
|
+
configurable: true,
|
|
5343
|
+
enumerable: false
|
|
5344
|
+
});
|
|
5345
|
+
}
|
|
5346
|
+
};
|
|
5300
5347
|
var DefaultManyToManyCollection = class {
|
|
5301
5348
|
/**
|
|
5302
5349
|
* @param ctx The entity context for tracking changes.
|
|
@@ -5320,6 +5367,7 @@ var DefaultManyToManyCollection = class {
|
|
|
5320
5367
|
this.createEntity = createEntity;
|
|
5321
5368
|
this.localKey = localKey;
|
|
5322
5369
|
hideInternal4(this, ["ctx", "meta", "root", "relationName", "relation", "rootTable", "loader", "createEntity", "localKey"]);
|
|
5370
|
+
hideWritable4(this, ["loaded", "items"]);
|
|
5323
5371
|
this.hydrateFromCache();
|
|
5324
5372
|
}
|
|
5325
5373
|
loaded = false;
|
|
@@ -5971,12 +6019,14 @@ var createEntityProxy = (ctx, table, row, lazyRelations = [], lazyRelationOption
|
|
|
5971
6019
|
const buildJson = (self) => {
|
|
5972
6020
|
const json = {};
|
|
5973
6021
|
for (const key of Object.keys(target)) {
|
|
6022
|
+
if (table.relations[key]) continue;
|
|
5974
6023
|
json[key] = self[key];
|
|
5975
6024
|
}
|
|
5976
|
-
for (const
|
|
5977
|
-
|
|
5978
|
-
if (isRelationWrapperLoaded(wrapper)) {
|
|
5979
|
-
|
|
6025
|
+
for (const relationName of Object.keys(table.relations)) {
|
|
6026
|
+
const wrapper = self[relationName];
|
|
6027
|
+
if (wrapper && isRelationWrapperLoaded(wrapper)) {
|
|
6028
|
+
const wrapperWithToJSON = wrapper;
|
|
6029
|
+
json[relationName] = typeof wrapperWithToJSON.toJSON === "function" ? wrapperWithToJSON.toJSON() : wrapper;
|
|
5980
6030
|
}
|
|
5981
6031
|
}
|
|
5982
6032
|
return json;
|