@bmstravel/nvp-plop-templates 0.2.64 → 0.2.66

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.
@@ -1,5 +1,4 @@
1
1
  import { DataTypes } from "sequelize";
2
- import dayjs from "dayjs";
3
2
  {{#eq dataTypeId "uuid"}}
4
3
  import { generateUuid } from '@bmstravel/nvp-utils'
5
4
  {{/eq}}
@@ -20,6 +19,7 @@ export interface I{{pascalCase name}} {
20
19
  // END addition here
21
20
  {{#if hasId}}
22
21
  status: STATUS
22
+ creator?: string
23
23
  createdBy?: any
24
24
  updatedBy?: any
25
25
  deleteBy?: any
@@ -57,16 +57,20 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
57
57
  values: Object.values(STATUS),
58
58
  defaultValue: STATUS.ACTIVE,
59
59
  },
60
+ creator: {
61
+ type: DataTypes.STRING,
62
+ allowNull: true,
63
+ },
60
64
  createdBy: {
61
- type: DataTypes.STRING(15),
65
+ type: DataTypes.STRING(50),
62
66
  allowNull: true,
63
67
  },
64
68
  updatedBy: {
65
- type: DataTypes.STRING(15),
69
+ type: DataTypes.STRING(50),
66
70
  allowNull: true,
67
71
  },
68
72
  deleteBy: {
69
- type: DataTypes.STRING(15),
73
+ type: DataTypes.STRING(50),
70
74
  allowNull: true,
71
75
  },
72
76
  isDelete: {
@@ -77,15 +81,30 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
77
81
  createdAt: {
78
82
  type: DataTypes.BIGINT,
79
83
  allowNull: false,
80
- {{!-- defaultValue: function () {
81
- return dayjs().valueOf()
82
- }, --}}
84
+ defaultValue: function () {
85
+ return new Date().getTime()
86
+ },
87
+ set(value: any) {
88
+ // const curVal = this.getDataValue("createdAt")
89
+ if (value == null || typeof value == "undefined") {
90
+ this.setDataValue("createdAt", new Date().getTime())
91
+ } else {
92
+ this.setDataValue("createdAt", value)
93
+ }
94
+ },
83
95
  },
84
96
  updatedAt: {
85
97
  type: DataTypes.BIGINT,
86
98
  allowNull: false,
87
99
  defaultValue: function () {
88
- return dayjs().valueOf()
100
+ return new Date().getTime()
101
+ },
102
+ set(value: any) {
103
+ if (value == null || typeof value == "undefined") {
104
+ this.setDataValue("updatedAt", new Date().getTime())
105
+ } else {
106
+ this.setDataValue("updatedAt", value)
107
+ }
89
108
  },
90
109
  },
91
110
  deletedAt: { type: DataTypes.BIGINT },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bmstravel/nvp-plop-templates",
3
- "version": "0.2.64",
3
+ "version": "0.2.66",
4
4
  "description": "🏆 Using for plop templates",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -15,5 +15,5 @@
15
15
  "phongnv86 <phongnguyenvan86@gmail.com>",
16
16
  "phongnv86 <phongnv@media-one.vn>"
17
17
  ],
18
- "gitHead": "0cf09176d0c1738657b2615a5cdf0e0f7b118df8"
18
+ "gitHead": "acfb8750bd568de52234c5f6b71a6bf5802f8b23"
19
19
  }