test-entity-library-asm 1.8.0 → 1.8.2

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.
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Partner = void 0;
13
13
  var typeorm_1 = require("typeorm");
14
+ var jsonTransformer_1 = require("../transformers/jsonTransformer");
14
15
  var City_1 = require("./City");
15
16
  var Company_1 = require("./Company");
16
17
  var DiscountCodeUser_1 = require("./DiscountCodeUser");
@@ -19,7 +20,6 @@ var PartnerRole_1 = require("./PartnerRole");
19
20
  var Terminal_1 = require("./Terminal");
20
21
  var TerminalSession_1 = require("./TerminalSession");
21
22
  var dateTransformer_1 = require("../transformers/dateTransformer");
22
- var jsonTransformer_1 = require("../transformers/jsonTransformer");
23
23
  var Partner = /** @class */ (function () {
24
24
  function Partner() {
25
25
  }
@@ -112,6 +112,7 @@ var Partner = /** @class */ (function () {
112
112
  ], Partner.prototype, "owner", void 0);
113
113
  __decorate([
114
114
  (0, typeorm_1.Column)({
115
+ type: 'datetime',
115
116
  transformer: new dateTransformer_1.DateTransformer(),
116
117
  comment: 'Fecha de creación del registro.',
117
118
  }),
@@ -1,5 +1,5 @@
1
1
  import { ValueTransformer } from 'typeorm';
2
2
  export declare class DateTransformer implements ValueTransformer {
3
- to(value: string): string;
3
+ to(value: Date | string): string;
4
4
  from(value: string): string;
5
5
  }
@@ -6,9 +6,12 @@ var DateTransformer = /** @class */ (function () {
6
6
  function DateTransformer() {
7
7
  }
8
8
  DateTransformer.prototype.to = function (value) {
9
+ console.log(value, 'Se lo trae del to');
10
+ // No es necesario transformar al guardar, se guarda en UTC
9
11
  return moment.utc(value).format('YYYY-MM-DD HH:mm:ss');
10
12
  };
11
13
  DateTransformer.prototype.from = function (value) {
14
+ // Convertir de UTC a la zona horaria local
12
15
  return moment.utc(value).tz('America/Bogota').format('YYYY-MM-DD HH:mm:ss');
13
16
  };
14
17
  return DateTransformer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-entity-library-asm",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Entidades de ejemplo para una base de datos",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,6 +8,7 @@ import {
8
8
  OneToMany,
9
9
  PrimaryGeneratedColumn,
10
10
  } from 'typeorm'
11
+ import { jsonTransformer } from '../transformers/jsonTransformer'
11
12
  import { City } from './City'
12
13
  import { Company } from './Company'
13
14
  import { DiscountCodeUser } from './DiscountCodeUser'
@@ -16,7 +17,6 @@ import { PartnerRole } from './PartnerRole'
16
17
  import { Terminal } from './Terminal'
17
18
  import { TerminalSession } from './TerminalSession'
18
19
  import { DateTransformer } from '../transformers/dateTransformer'
19
- import { jsonTransformer } from '../transformers/jsonTransformer'
20
20
 
21
21
  @Entity({
22
22
  comment:
@@ -100,6 +100,7 @@ export class Partner {
100
100
  owner: number
101
101
 
102
102
  @Column({
103
+ type: 'datetime',
103
104
  transformer: new DateTransformer(),
104
105
  comment: 'Fecha de creación del registro.',
105
106
  })
@@ -2,11 +2,15 @@ import { ValueTransformer } from 'typeorm'
2
2
  import * as moment from 'moment-timezone'
3
3
 
4
4
  export class DateTransformer implements ValueTransformer {
5
- to(value: string): string {
5
+ to(value: Date | string): string {
6
+ console.log(value, 'Se lo trae del to')
7
+
8
+ // No es necesario transformar al guardar, se guarda en UTC
6
9
  return moment.utc(value).format('YYYY-MM-DD HH:mm:ss')
7
10
  }
8
11
 
9
12
  from(value: string): string {
13
+ // Convertir de UTC a la zona horaria local
10
14
  return moment.utc(value).tz('America/Bogota').format('YYYY-MM-DD HH:mm:ss')
11
15
  }
12
16
  }