@mikro-orm/core 6.3.14-dev.32 → 6.3.14-dev.34
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.3.14-dev.
|
|
3
|
+
"version": "6.3.14-dev.34",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.3.14-dev.
|
|
67
|
+
"mikro-orm": "6.3.14-dev.34",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -111,7 +111,7 @@ class EntitySerializer {
|
|
|
111
111
|
const parts = prop.split('.');
|
|
112
112
|
prop = parts[0];
|
|
113
113
|
const wrapped = (0, wrap_1.helper)(entity);
|
|
114
|
-
const property = wrapped.__meta.properties[prop];
|
|
114
|
+
const property = wrapped.__meta.properties[prop] ?? { name: prop };
|
|
115
115
|
const serializer = property?.serializer;
|
|
116
116
|
const value = entity[prop];
|
|
117
117
|
// getter method
|
|
@@ -127,10 +127,10 @@ class EntitySerializer {
|
|
|
127
127
|
return serializer(value);
|
|
128
128
|
}
|
|
129
129
|
if (Utils_1.Utils.isCollection(value)) {
|
|
130
|
-
return this.processCollection(
|
|
130
|
+
return this.processCollection(property, entity, options);
|
|
131
131
|
}
|
|
132
132
|
if (Utils_1.Utils.isEntity(value, true)) {
|
|
133
|
-
return this.processEntity(
|
|
133
|
+
return this.processEntity(property, entity, wrapped.__platform, options);
|
|
134
134
|
}
|
|
135
135
|
if (Utils_1.Utils.isScalarReference(value)) {
|
|
136
136
|
return value.unwrap();
|
|
@@ -158,17 +158,20 @@ class EntitySerializer {
|
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
static processEntity(prop, entity, platform, options) {
|
|
161
|
-
const child = Reference_1.Reference.unwrapReference(entity[prop]);
|
|
161
|
+
const child = Reference_1.Reference.unwrapReference(entity[prop.name]);
|
|
162
162
|
const wrapped = (0, wrap_1.helper)(child);
|
|
163
|
-
const populated = isPopulated(prop, options) && wrapped.isInitialized();
|
|
163
|
+
const populated = isPopulated(prop.name, options) && wrapped.isInitialized();
|
|
164
164
|
const expand = populated || !wrapped.__managed;
|
|
165
165
|
const meta = wrapped.__meta;
|
|
166
|
-
const childOptions = this.extractChildOptions(options, prop);
|
|
166
|
+
const childOptions = this.extractChildOptions(options, prop.name);
|
|
167
167
|
const visible = meta.primaryKeys.filter(prop => isVisible(meta, prop, childOptions));
|
|
168
168
|
if (expand) {
|
|
169
169
|
return this.serialize(child, childOptions);
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
let pk = wrapped.getPrimaryKey();
|
|
172
|
+
if (prop.customType) {
|
|
173
|
+
pk = prop.customType.toJSON(pk, wrapped.__platform);
|
|
174
|
+
}
|
|
172
175
|
if (options.forceObject || wrapped.__config.get('serialization').forceObject) {
|
|
173
176
|
return Utils_1.Utils.primaryKeyToObject(meta, pk, visible);
|
|
174
177
|
}
|
|
@@ -182,20 +185,24 @@ class EntitySerializer {
|
|
|
182
185
|
return platform.normalizePrimaryKey(pk);
|
|
183
186
|
}
|
|
184
187
|
static processCollection(prop, entity, options) {
|
|
185
|
-
const col = entity[prop];
|
|
188
|
+
const col = entity[prop.name];
|
|
186
189
|
if (!col.isInitialized()) {
|
|
187
190
|
return undefined;
|
|
188
191
|
}
|
|
189
192
|
return col.getItems(false).map(item => {
|
|
190
|
-
const populated = isPopulated(prop, options);
|
|
193
|
+
const populated = isPopulated(prop.name, options);
|
|
191
194
|
const wrapped = (0, wrap_1.helper)(item);
|
|
192
195
|
if (populated || !wrapped.__managed) {
|
|
193
|
-
return this.serialize(item, this.extractChildOptions(options, prop));
|
|
196
|
+
return this.serialize(item, this.extractChildOptions(options, prop.name));
|
|
197
|
+
}
|
|
198
|
+
let pk = wrapped.getPrimaryKey();
|
|
199
|
+
if (prop.customType) {
|
|
200
|
+
pk = prop.customType.toJSON(pk, wrapped.__platform);
|
|
194
201
|
}
|
|
195
202
|
if (options.forceObject || wrapped.__config.get('serialization').forceObject) {
|
|
196
|
-
return Utils_1.Utils.primaryKeyToObject(wrapped.__meta,
|
|
203
|
+
return Utils_1.Utils.primaryKeyToObject(wrapped.__meta, pk);
|
|
197
204
|
}
|
|
198
|
-
return
|
|
205
|
+
return pk;
|
|
199
206
|
});
|
|
200
207
|
}
|
|
201
208
|
}
|
|
@@ -108,7 +108,7 @@ class EntityTransformer {
|
|
|
108
108
|
}
|
|
109
109
|
static processProperty(prop, entity, raw, populated) {
|
|
110
110
|
const wrapped = (0, wrap_1.helper)(entity);
|
|
111
|
-
const property = wrapped.__meta.properties[prop];
|
|
111
|
+
const property = wrapped.__meta.properties[prop] ?? { name: prop };
|
|
112
112
|
const serializer = property?.serializer;
|
|
113
113
|
const value = entity[prop];
|
|
114
114
|
// getter method
|
|
@@ -123,10 +123,10 @@ class EntityTransformer {
|
|
|
123
123
|
return serializer(value);
|
|
124
124
|
}
|
|
125
125
|
if (Utils_1.Utils.isCollection(value)) {
|
|
126
|
-
return EntityTransformer.processCollection(
|
|
126
|
+
return EntityTransformer.processCollection(property, entity, raw, populated);
|
|
127
127
|
}
|
|
128
128
|
if (Utils_1.Utils.isEntity(value, true)) {
|
|
129
|
-
return EntityTransformer.processEntity(
|
|
129
|
+
return EntityTransformer.processEntity(property, entity, wrapped.__platform, raw, populated);
|
|
130
130
|
}
|
|
131
131
|
if (Utils_1.Utils.isScalarReference(value)) {
|
|
132
132
|
return value.unwrap();
|
|
@@ -151,7 +151,7 @@ class EntityTransformer {
|
|
|
151
151
|
return value;
|
|
152
152
|
}
|
|
153
153
|
static processEntity(prop, entity, platform, raw, populated) {
|
|
154
|
-
const child = entity[prop];
|
|
154
|
+
const child = entity[prop.name];
|
|
155
155
|
const wrapped = (0, wrap_1.helper)(child);
|
|
156
156
|
const meta = wrapped.__meta;
|
|
157
157
|
const visible = meta.primaryKeys.filter(prop => isVisible(meta, prop));
|
|
@@ -170,7 +170,10 @@ class EntityTransformer {
|
|
|
170
170
|
if (wrapped.isInitialized() && isPopulated() && child !== entity) {
|
|
171
171
|
return (0, wrap_1.wrap)(child).toJSON();
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
let pk = wrapped.getPrimaryKey();
|
|
174
|
+
if (prop.customType) {
|
|
175
|
+
pk = prop.customType.toJSON(pk, wrapped.__platform);
|
|
176
|
+
}
|
|
174
177
|
if (wrapped.__config.get('serialization').forceObject) {
|
|
175
178
|
return Utils_1.Utils.primaryKeyToObject(meta, pk, visible);
|
|
176
179
|
}
|
|
@@ -184,7 +187,7 @@ class EntityTransformer {
|
|
|
184
187
|
return platform.normalizePrimaryKey(pk);
|
|
185
188
|
}
|
|
186
189
|
static processCollection(prop, entity, raw, populated) {
|
|
187
|
-
const col = entity[prop];
|
|
190
|
+
const col = entity[prop.name];
|
|
188
191
|
if (raw && col.isInitialized(true)) {
|
|
189
192
|
return col.map(item => (0, wrap_1.helper)(item).toPOJO());
|
|
190
193
|
}
|
|
@@ -193,13 +196,18 @@ class EntityTransformer {
|
|
|
193
196
|
}
|
|
194
197
|
if (col.isInitialized()) {
|
|
195
198
|
const wrapped = (0, wrap_1.helper)(entity);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
const forceObject = wrapped.__config.get('serialization').forceObject;
|
|
200
|
+
return col.map(item => {
|
|
201
|
+
const wrapped = (0, wrap_1.helper)(item);
|
|
202
|
+
const pk = wrapped.getPrimaryKey();
|
|
203
|
+
if (prop.customType) {
|
|
204
|
+
return prop.customType.toJSON(pk, wrapped.__platform);
|
|
205
|
+
}
|
|
206
|
+
if (forceObject) {
|
|
207
|
+
return Utils_1.Utils.primaryKeyToObject(wrapped.__meta, pk);
|
|
208
|
+
}
|
|
209
|
+
return pk;
|
|
210
|
+
});
|
|
203
211
|
}
|
|
204
212
|
return undefined;
|
|
205
213
|
}
|