@cheetah.js/orm 0.1.49 → 0.1.50

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.
@@ -9,12 +9,13 @@ 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
- const type = core_1.Metadata.getType(target, propertyKey);
13
- const length = (options && options.length) || (0, utils_1.getDefaultLength)(type.name);
12
+ // 1) Resolva o tipo logo no início
13
+ const propType = core_1.Metadata.getType(target, propertyKey);
14
+ const length = (options && options.length) || (0, utils_1.getDefaultLength)(propType?.name);
14
15
  options = { length, ...options };
15
16
  options["columnName"] = options?.columnName || (0, utils_1.toSnakeCase)(propertyKey);
16
- if ((0, utils_1.extendsFrom)(__1.ValueObject, type.prototype)) {
17
- let instance = new type(null, true).getDatabaseValues();
17
+ if (propType && (0, utils_1.extendsFrom)(__1.ValueObject, propType.prototype)) {
18
+ let instance = new propType(null, true).getDatabaseValues();
18
19
  options["length"] = instance.max;
19
20
  options["precision"] = instance.precision;
20
21
  options["scale"] = instance.scale;
@@ -30,11 +31,9 @@ function Property(options) {
30
31
  if (options.index) {
31
32
  (0, index_decorator_1.Index)({ properties: [propertyKey] })(target, propertyKey);
32
33
  }
33
- properties.forEach((property) => {
34
- const types = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, target.constructor) || {};
35
- const type = core_1.Metadata.getType(target, property.propertyKey);
36
- types[property.propertyKey] = { type, options: property.options };
37
- core_1.Metadata.set(constants_1.PROPERTIES_METADATA, types, target.constructor);
38
- });
34
+ // 2) Atualize PROPERTIES_METADATA apenas para esta propriedade
35
+ const types = core_1.Metadata.get(constants_1.PROPERTIES_METADATA, target.constructor) || {};
36
+ types[propertyKey] = { type: propType, options };
37
+ core_1.Metadata.set(constants_1.PROPERTIES_METADATA, types, target.constructor);
39
38
  };
40
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cheetah.js/orm",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "description": "A simple ORM for Cheetah.js",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -50,5 +50,5 @@
50
50
  "bun",
51
51
  "value-object"
52
52
  ],
53
- "gitHead": "89bb2e0f01226bc4d3e46a24644dbe17cf043150"
53
+ "gitHead": "d6713552362cda71d36da76b96718331fc1997b7"
54
54
  }