@ghom/orm 1.7.0 → 1.7.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.
@@ -43,7 +43,9 @@ class Table {
43
43
  throw new Error("missing ORM");
44
44
  try {
45
45
  await this.db.schema.createTable(this.options.name, this.options.setup);
46
- this.orm.config.logger?.log(`created table ${chalk_1.default[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}`);
46
+ this.orm.config.logger?.log(`created table ${chalk_1.default[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}${this.options.description
47
+ ? ` ${chalk_1.default[this.orm.config.loggerColors?.description ?? "grey"](this.options.description)}`
48
+ : ""}`);
47
49
  }
48
50
  catch (error) {
49
51
  if (error.toString().includes("syntax error")) {
@@ -51,7 +53,9 @@ class Table {
51
53
  throw error;
52
54
  }
53
55
  else {
54
- this.orm.config.logger?.log(`loaded table ${chalk_1.default[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}`);
56
+ this.orm.config.logger?.log(`loaded table ${chalk_1.default[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}${this.options.description
57
+ ? ` ${chalk_1.default[this.orm.config.loggerColors?.description ?? "grey"](this.options.description)}`
58
+ : ""}`);
55
59
  }
56
60
  }
57
61
  try {
@@ -39,7 +39,9 @@ export class Table {
39
39
  throw new Error("missing ORM");
40
40
  try {
41
41
  await this.db.schema.createTable(this.options.name, this.options.setup);
42
- this.orm.config.logger?.log(`created table ${chalk[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}`);
42
+ this.orm.config.logger?.log(`created table ${chalk[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}${this.options.description
43
+ ? ` ${chalk[this.orm.config.loggerColors?.description ?? "grey"](this.options.description)}`
44
+ : ""}`);
43
45
  }
44
46
  catch (error) {
45
47
  if (error.toString().includes("syntax error")) {
@@ -47,7 +49,9 @@ export class Table {
47
49
  throw error;
48
50
  }
49
51
  else {
50
- this.orm.config.logger?.log(`loaded table ${chalk[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}`);
52
+ this.orm.config.logger?.log(`loaded table ${chalk[this.orm.config.loggerColors?.highlight ?? "blueBright"](this.options.name)}${this.options.description
53
+ ? ` ${chalk[this.orm.config.loggerColors?.description ?? "grey"](this.options.description)}`
54
+ : ""}`);
51
55
  }
52
56
  }
53
57
  try {
@@ -27,6 +27,7 @@ export interface ORMConfig {
27
27
  loggerColors?: {
28
28
  highlight: typeof Color;
29
29
  rawValue: typeof Color;
30
+ description: typeof Color;
30
31
  };
31
32
  }
32
33
  export declare class ORM {
@@ -6,6 +6,7 @@ export interface MigrationData {
6
6
  }
7
7
  export interface TableOptions<Type extends object = object> {
8
8
  name: string;
9
+ description?: string;
9
10
  priority?: number;
10
11
  migrations?: {
11
12
  [version: number]: (table: Knex.CreateTableBuilder) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghom/orm",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
package/src/app/orm.ts CHANGED
@@ -42,6 +42,7 @@ export interface ORMConfig {
42
42
  loggerColors?: {
43
43
  highlight: typeof Color
44
44
  rawValue: typeof Color
45
+ description: typeof Color
45
46
  }
46
47
  }
47
48
 
package/src/app/table.ts CHANGED
@@ -9,6 +9,7 @@ export interface MigrationData {
9
9
 
10
10
  export interface TableOptions<Type extends object = object> {
11
11
  name: string
12
+ description?: string
12
13
  priority?: number
13
14
  migrations?: { [version: number]: (table: Knex.CreateTableBuilder) => void }
14
15
  then?: (this: Table<Type>, table: Table<Type>) => unknown
@@ -67,7 +68,13 @@ export class Table<Type extends object = object> {
67
68
  this.orm.config.logger?.log(
68
69
  `created table ${chalk[
69
70
  this.orm.config.loggerColors?.highlight ?? "blueBright"
70
- ](this.options.name)}`,
71
+ ](this.options.name)}${
72
+ this.options.description
73
+ ? ` ${chalk[this.orm.config.loggerColors?.description ?? "grey"](
74
+ this.options.description,
75
+ )}`
76
+ : ""
77
+ }`,
71
78
  )
72
79
  } catch (error: any) {
73
80
  if (error.toString().includes("syntax error")) {
@@ -82,7 +89,13 @@ export class Table<Type extends object = object> {
82
89
  this.orm.config.logger?.log(
83
90
  `loaded table ${chalk[
84
91
  this.orm.config.loggerColors?.highlight ?? "blueBright"
85
- ](this.options.name)}`,
92
+ ](this.options.name)}${
93
+ this.options.description
94
+ ? ` ${chalk[this.orm.config.loggerColors?.description ?? "grey"](
95
+ this.options.description,
96
+ )}`
97
+ : ""
98
+ }`,
86
99
  )
87
100
  }
88
101
  }