@zenorm/generate 1.7.0 → 1.8.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.8.1] - 2023-5-19
4
+ - fix: 使用 global 继承时构造函数缺少 super 调用
5
+
6
+ ## [1.8.0] - 2023-5-18
7
+ - 撤销 [1.6.0] 的修改,动态 as 功能无法满足需求
8
+
3
9
  ## [1.7.0] - 2023-5-18
4
10
  - 构造器增加 pkval 参数
5
11
 
package/dist/generate.js CHANGED
@@ -18,7 +18,6 @@ async function generate(tables, cfg) {
18
18
  await (0, utils_1.checkFileDir)(outputDir);
19
19
  console.log('database:', config.database);
20
20
  const remark = [
21
- `// @ts-nocheck`,
22
21
  '// zenorm 自动生成文件',
23
22
  '// 请不要修改此文件,因为此文件在每次重新生成数据库结构时会被覆盖',
24
23
  `// create at: ${(0, utils_1.currentDatetime)()}`,
@@ -67,12 +66,11 @@ async function generate(tables, cfg) {
67
66
  structs.push(` static columns = ${JSON.stringify(columns)};`);
68
67
  structs.push(...props);
69
68
  structs.push('');
70
- // 使用构造器提前初始化对象的属性,用于优化 v8 对象缓存机制
71
- structs.push(` constructor(pkval?: ${pkType}, data: Partial<${className}Table> = {}) {`);
72
- structs.push(` this.__pk = pkval;`);
73
- for (const c of columns) {
74
- structs.push(` this.${c} = data.${c};`);
69
+ structs.push(` constructor(data?: object) {`);
70
+ if (config.globalFilename) {
71
+ structs.push(` super();`);
75
72
  }
73
+ structs.push(` data && Object.assign(this, data);`);
76
74
  structs.push(` }`);
77
75
  structs.push('}');
78
76
  structs.push('');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zenorm/generate",
3
3
  "description": "Easy ORM, easy query. easy typing! Auto generate typescript declaration.",
4
- "version": "1.7.0",
4
+ "version": "1.8.1",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "homepage": "https://zenorm.node.ltd",