@carno.js/orm 0.2.8 → 0.2.10
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/SqlBuilder.js
CHANGED
|
@@ -147,10 +147,10 @@ class SqlBuilder {
|
|
|
147
147
|
return this;
|
|
148
148
|
}
|
|
149
149
|
getPrimaryKeyColumnName(entity) {
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
//
|
|
150
|
+
// Logic to resolve the entity primary key column name
|
|
151
|
+
// Replace this with your own logic based on your project structure
|
|
152
|
+
// For example, if the primary key is always 'id', you can return 'id'.
|
|
153
|
+
// If the logic becomes more complex, add a method on Options to resolve the primary key.
|
|
154
154
|
return 'id';
|
|
155
155
|
}
|
|
156
156
|
shouldUseCache() {
|
|
@@ -43,8 +43,8 @@ export declare abstract class ValueObject<T, Vo> {
|
|
|
43
43
|
protected scale?: number;
|
|
44
44
|
/**
|
|
45
45
|
* Valor do Value Object.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* It is private to prevent direct changes.
|
|
47
|
+
* The value is immutable as well.
|
|
48
48
|
*
|
|
49
49
|
* @private
|
|
50
50
|
*/
|
|
@@ -9,7 +9,7 @@ const __1 = require("..");
|
|
|
9
9
|
function Property(options) {
|
|
10
10
|
return (target, propertyKey) => {
|
|
11
11
|
const properties = core_1.Metadata.get(constants_1.PROPERTIES, target.constructor) || [];
|
|
12
|
-
// 1)
|
|
12
|
+
// 1) Resolve the type as early as possible
|
|
13
13
|
const propType = core_1.Metadata.getType(target, propertyKey);
|
|
14
14
|
const length = (options && options.length) || (0, utils_1.getDefaultLength)(propType?.name);
|
|
15
15
|
if ((0, core_1.isObject)(propType) && options.dbType !== "enum") {
|
|
@@ -36,7 +36,7 @@ function Property(options) {
|
|
|
36
36
|
}
|
|
37
37
|
// 2) Atualize PROPERTIES_METADATA apenas para esta propriedade
|
|
38
38
|
const existingTypes = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, target.constructor) || {};
|
|
39
|
-
//
|
|
39
|
+
// Create a copy to avoid shared mutation between entities
|
|
40
40
|
const types = { ...existingTypes };
|
|
41
41
|
types[propertyKey] = { type: propType, options };
|
|
42
42
|
core_1.Metadata.set(constants_1.PROPERTIES_METADATA, types, target.constructor);
|
package/dist/domain/entities.js
CHANGED
|
@@ -234,7 +234,7 @@ let EntityStorage = EntityStorage_1 = class EntityStorage {
|
|
|
234
234
|
* @param relationShip
|
|
235
235
|
*/
|
|
236
236
|
getFkKey(relationShip) {
|
|
237
|
-
//
|
|
237
|
+
// if nullable, it should return the primary key of the target entity
|
|
238
238
|
if (typeof relationShip.fkKey === "undefined") {
|
|
239
239
|
const entity = this.entities.get(relationShip.entity());
|
|
240
240
|
const property = Object.entries(entity.properties).find(([_key, value]) => value.options.isPrimary === true);
|
|
@@ -243,7 +243,7 @@ let EntityStorage = EntityStorage_1 = class EntityStorage {
|
|
|
243
243
|
}
|
|
244
244
|
return property[0];
|
|
245
245
|
}
|
|
246
|
-
//
|
|
246
|
+
// if fkKey is a function, it will return the property that is the foreign key
|
|
247
247
|
// precisamos pegar o nome dessa propriedade
|
|
248
248
|
if (typeof relationShip.fkKey === "string") {
|
|
249
249
|
return relationShip.fkKey;
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Carno } from '@carno.js/core';
|
|
2
|
-
export declare const CarnoOrm: Carno
|
|
2
|
+
export declare const CarnoOrm: Carno<import("@carno.js/core").ValidatorAdapterConstructor>;
|
package/dist/orm.service.js
CHANGED
|
@@ -290,7 +290,7 @@ let OrmService = class OrmService {
|
|
|
290
290
|
const propertiesFromMetadata = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, entity.target);
|
|
291
291
|
const relationshipsFromMetadata = core_1.Metadata.get(constants_1.PROPERTIES_RELATIONS, entity.target) || [];
|
|
292
292
|
const hooks = core_1.Metadata.get(constants_1.EVENTS_METADATA, entity.target);
|
|
293
|
-
//
|
|
293
|
+
// Create a deep copy of properties to avoid shared mutation
|
|
294
294
|
const properties = {};
|
|
295
295
|
if (propertiesFromMetadata) {
|
|
296
296
|
for (const [key, value] of Object.entries(propertiesFromMetadata)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carno.js/orm",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "A simple ORM for Carno.js.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"bun",
|
|
56
56
|
"value-object"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "5c765c2c9172bec7f509ca2513f6c10472ec89eb"
|
|
59
59
|
}
|