tspace-mysql 1.4.0 → 1.4.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.
package/README.md CHANGED
@@ -1001,9 +1001,9 @@ tspace-mysql query "SELECT * FROM users"
1001
1001
  # Dump
1002
1002
  Command will be dump database or table into file
1003
1003
  ```js
1004
- tspace-mysql dump:db --db=database --values
1004
+ tspace-mysql dump:db "database" --values // backup with values in the tables
1005
1005
 
1006
- tspace-mysql dump:table --table=table --values
1006
+ tspace-mysql dump:table "table" --values // backup with values in the table
1007
1007
 
1008
1008
  ```
1009
1009
 
@@ -1011,6 +1011,8 @@ tspace-mysql dump:table --table=table --values
1011
1011
  Command will be generate models from table in database
1012
1012
  ```js
1013
1013
  tspace-mysql generate:models --dir=<folder for creating>
1014
+ or
1015
+ tspace-mysql gen:models --dir=<folder for creating>
1014
1016
 
1015
1017
  ```
1016
1018
 
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const lib_1 = require("../../lib");
4
4
  exports.default = (cmd) => {
5
- const { dir, cwd, fs, values, db } = cmd;
5
+ const { dir, cwd, fs, values, env, sql } = cmd;
6
6
  if (dir) {
7
7
  try {
8
8
  fs.accessSync(`${cwd}/${dir}`, fs.F_OK, {
@@ -15,24 +15,26 @@ exports.default = (cmd) => {
15
15
  });
16
16
  }
17
17
  }
18
- if (values) {
19
- const directory = `${cwd}/${dir}/dump-schema_${+new Date()}.sql`;
20
- new lib_1.DB().backupSchemaToFile({
21
- filePath: directory,
22
- database: db
23
- })
24
- .then(r => console.log(`dump schema database "${db}" file successfully`))
25
- .catch(err => console.log(err))
26
- .finally(() => process.exit(0));
18
+ if (sql == null || sql === '') {
19
+ console.log(`Example tspace-mysql dump:db "table" --dir=app/table`);
20
+ process.exit(0);
27
21
  }
28
- else {
29
- const directory = `${cwd}/${dir}/dump_${+new Date()}.sql`;
30
- new lib_1.DB().backupToFile({
22
+ if (!values) {
23
+ const directory = `${cwd}/${dir}/dump-schema_${+new Date()}.sql`;
24
+ new lib_1.DB().loadEnv(env).backupSchemaToFile({
31
25
  filePath: directory,
32
- database: db
26
+ database: sql
33
27
  })
34
- .then(r => console.log(`dump database "${db}" file successfully`))
28
+ .then(r => console.log(`dump schema database "${sql}" file successfully`))
35
29
  .catch(err => console.log(err))
36
30
  .finally(() => process.exit(0));
37
31
  }
32
+ const directory = `${cwd}/${dir}/dump_${+new Date()}.sql`;
33
+ new lib_1.DB().loadEnv(env).backupToFile({
34
+ filePath: directory,
35
+ database: sql
36
+ })
37
+ .then(r => console.log(`dump database "${sql}" file successfully`))
38
+ .catch(err => console.log(err))
39
+ .finally(() => process.exit(0));
38
40
  };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const lib_1 = require("../../lib");
4
4
  exports.default = (cmd) => {
5
- const { dir, cwd, fs, values, table } = cmd;
5
+ const { dir, cwd, fs, values, sql } = cmd;
6
6
  if (dir) {
7
7
  try {
8
8
  fs.accessSync(`${cwd}/${dir}`, fs.F_OK, {
@@ -15,24 +15,26 @@ exports.default = (cmd) => {
15
15
  });
16
16
  }
17
17
  }
18
- if (values) {
18
+ if (sql == null || sql === '') {
19
+ console.log(`Example tspace-mysql dump:table "table" --dir=app/table`);
20
+ process.exit(0);
21
+ }
22
+ if (!values) {
19
23
  const directory = `${cwd}/${dir}/dump-schema_${+new Date()}.sql`;
20
24
  new lib_1.DB().backupTableSchemaToFile({
21
25
  filePath: directory,
22
- table
23
- })
24
- .then(r => console.log(`dump table schema "${table}" file successfully`))
25
- .catch(err => console.log(err))
26
- .finally(() => process.exit(0));
27
- }
28
- else {
29
- const directory = `${cwd}/${dir}/dump_${+new Date()}.sql`;
30
- new lib_1.DB().backupTableToFile({
31
- filePath: directory,
32
- table
26
+ table: sql
33
27
  })
34
- .then(r => console.log(`dump table "${table}" file successfully`))
28
+ .then(r => console.log(`dump table schema "${sql}" file successfully`))
35
29
  .catch(err => console.log(err))
36
30
  .finally(() => process.exit(0));
37
31
  }
32
+ const directory = `${cwd}/${dir}/dump_${+new Date()}.sql`;
33
+ new lib_1.DB().backupTableToFile({
34
+ filePath: directory,
35
+ table: sql
36
+ })
37
+ .then(r => console.log(`dump table "${sql}" file successfully`))
38
+ .catch(err => console.log(err))
39
+ .finally(() => process.exit(0));
38
40
  };
@@ -7,7 +7,7 @@ const model_1 = __importDefault(require("./model"));
7
7
  const pluralize_1 = __importDefault(require("pluralize"));
8
8
  const lib_1 = require("../../lib");
9
9
  exports.default = (cmd) => {
10
- const { dir, cwd, type, fs, npm } = cmd;
10
+ const { dir, cwd, type, fs, env, npm } = cmd;
11
11
  if (dir) {
12
12
  try {
13
13
  fs.accessSync(`${cwd}/${dir}`, fs.F_OK, {
@@ -27,26 +27,48 @@ exports.default = (cmd) => {
27
27
  }
28
28
  return str.join('');
29
29
  };
30
- new lib_1.DB().rawQuery('SHOW TABLES')
30
+ const formatSchema = (data) => {
31
+ const formattedCode = {};
32
+ for (const field of data) {
33
+ const [key, value] = field.split(":").map((item) => item.trim());
34
+ formattedCode[key] = value;
35
+ }
36
+ return formattedCode;
37
+ };
38
+ new lib_1.DB()
39
+ .loadEnv(env)
40
+ .rawQuery('SHOW TABLES')
31
41
  .then(tables => {
32
42
  var _a;
33
43
  for (let i = 0; i < tables.length; i++) {
34
44
  const table = String((_a = Object.values(tables[i])) === null || _a === void 0 ? void 0 : _a.shift());
35
45
  const model = snakeCaseToPascal(pluralize_1.default.singular(table));
36
- new lib_1.DB().rawQuery(`SHOW COLUMNS FROM ${table}`).then(raw => {
37
- let schema = '';
38
- for (const r of raw) {
39
- schema += `${r.Field} : `;
40
- schema += `new Blueprint().${/^[^()]*$/.test(r.Type) ? `${r.Type.toLocaleLowerCase()}()` : r.Type.toLocaleLowerCase()}`;
41
- schema += `${r.Null === 'YES' ? '.null()' : '.notNull()'}`;
42
- schema += r.Key === 'PRI' ? '.primary()' : r.Key === 'UNI' ? '.unique()' : '';
43
- schema += r.Default != null ? `.default('${r.Default}')` : '';
44
- schema += `${r.Extra === 'auto_increment' ? '.autoIncrement()' : ''},
45
- `;
46
+ new lib_1.DB().loadEnv(env).rawQuery(`SHOW COLUMNS FROM \`${table}\``).then(raws => {
47
+ let schema = [];
48
+ for (const index in raws) {
49
+ const raw = raws[i];
50
+ const str = [
51
+ `${raw.Field} : `,
52
+ `new Blueprint().${/^[^()]*$/.test(raw.Type)
53
+ ? raw.Type === 'int unsigned'
54
+ ? 'int().unsigned()'
55
+ : `${raw.Type.toLocaleLowerCase()}()`
56
+ : raw.Type.toLocaleLowerCase()}`,
57
+ `${raw.Null === 'YES' ? '.null()' : '.notNull()'}`,
58
+ raw.Key === 'PRI' ? '.primary()' : raw.Key === 'UNI' ? '.unique()' : '',
59
+ raw.Default != null ? `.default('${raw.Default}')` : '',
60
+ `${raw.Extra === 'auto_increment' ? '.autoIncrement()' : ''},`
61
+ ].join('');
62
+ const isLast = Number(index) + 1 === raws.length;
63
+ schema.push(isLast ? str.replace(/,\s*$/, "") : str);
64
+ }
65
+ const formattedSchema = formatSchema(schema);
66
+ let str = "this.useSchema({\n";
67
+ for (const formatKey in formattedSchema) {
68
+ str += ` ${formatKey} : ${formattedSchema[formatKey]} \n`;
46
69
  }
47
- const data = (0, model_1.default)(model, npm, `this.useSchema({
48
- ${schema.replace(/,\s*$/, "")}
49
- })`);
70
+ str += " })";
71
+ const data = (0, model_1.default)(model, npm, `${str}`);
50
72
  fs.writeFile(`${cwd}/${dir}/${model}${type !== null && type !== void 0 ? type : '.ts'}`, data, (err) => {
51
73
  if (err)
52
74
  throw err;
@@ -57,6 +79,5 @@ exports.default = (cmd) => {
57
79
  }
58
80
  console.log('\nGenerate Models has completed');
59
81
  })
60
- .catch(err => console.log(err))
61
- .finally(() => process.exit(0));
82
+ .catch(err => console.log(err));
62
83
  };
package/dist/cli/index.js CHANGED
@@ -12,7 +12,7 @@ const make_3 = __importDefault(require("./migrate/make"));
12
12
  const make_4 = __importDefault(require("./generate/make"));
13
13
  const query_1 = __importDefault(require("./query"));
14
14
  const db_1 = __importDefault(require("./dump/db"));
15
- const db_2 = __importDefault(require("./dump/db"));
15
+ const table_1 = __importDefault(require("./dump/table"));
16
16
  const commands = {
17
17
  'query': query_1.default,
18
18
  'make:model': make_1.default,
@@ -22,7 +22,7 @@ const commands = {
22
22
  'generate:models': make_4.default,
23
23
  'gen:models': make_4.default,
24
24
  'dump:db': db_1.default,
25
- 'dump:table': db_2.default
25
+ 'dump:table': table_1.default
26
26
  };
27
27
  try {
28
28
  const name = (_c = (_b = (_a = process.argv.slice(2)) === null || _a === void 0 ? void 0 : _a.find(data => {
@@ -62,19 +62,22 @@ try {
62
62
  db,
63
63
  table,
64
64
  values,
65
+ env,
65
66
  npm: 'tspace-mysql'
66
67
  };
67
68
  commands[process.argv[2]](cmd);
68
69
  }
69
70
  catch (err) {
70
71
  console.log(`
71
- tspace-mysql make:model User --m --dir=app/Models
72
- tspace-mysql make:migration users --dir=app/Models/Migrations
73
- tspace-mysql migrate --dir=App/Models/Migrations --type=js
74
- tspace-mysql query "SELECT * FROM users"
75
- tspace-mysql generate:models --dir=app/Models
76
- tspace-mysql dump:db --db=database --dir=app/db
77
- tspace-mysql dump:table --table=table --dir=app/table
72
+ \x1b[31m
73
+ tspace-mysql make:model User --m --dir=app/Models
74
+ tspace-mysql make:migration users --dir=app/Models/Migrations
75
+ tspace-mysql migrate --dir=App/Models/Migrations --type=js
76
+ tspace-mysql query "SELECT * FROM users" --env=development
77
+ tspace-mysql generate:models --dir=app/Models --env=development
78
+ tspace-mysql dump:db "database" --dir=app/db --v --env=development
79
+ tspace-mysql dump:table "table" --dir=app/table --v --env=development
80
+ \x1b[0m
78
81
  `);
79
82
  console.log(`Read more https://www.npmjs.com/package/tspace-mysql`);
80
83
  process.exit(0);
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const lib_1 = require("../../lib");
4
4
  exports.default = (cmd) => {
5
- const { sql } = cmd;
6
- new lib_1.DB().rawQuery(sql === null || sql === void 0 ? void 0 : sql.replace(/`/g, ''))
5
+ const { sql, env } = cmd;
6
+ new lib_1.DB().loadEnv(env).rawQuery(sql === null || sql === void 0 ? void 0 : sql.replace(/`/g, ''))
7
7
  .then(result => console.log(result))
8
8
  .catch(err => console.log(err))
9
9
  .finally(() => process.exit(0));
@@ -1,4 +1,6 @@
1
+ import { loadOptionsEnvironment } from './options';
1
2
  import { Connection, Options } from '../tspace/Interface';
3
+ export { loadOptionsEnvironment };
2
4
  export declare class PoolConnection {
3
5
  private OPTIONS;
4
6
  /**
@@ -1,12 +1,36 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Pool = exports.PoolConnection = void 0;
29
+ exports.Pool = exports.PoolConnection = exports.loadOptionsEnvironment = void 0;
7
30
  const fs_1 = __importDefault(require("fs"));
8
31
  const path_1 = __importDefault(require("path"));
9
- const options_1 = __importDefault(require("./options"));
32
+ const options_1 = __importStar(require("./options"));
33
+ Object.defineProperty(exports, "loadOptionsEnvironment", { enumerable: true, get: function () { return options_1.loadOptionsEnvironment; } });
10
34
  const mysql2_1 = require("mysql2");
11
35
  class PoolConnection {
12
36
  /**
@@ -1,3 +1,21 @@
1
+ export declare const loadOptionsEnvironment: () => Readonly<{
2
+ [x: string]: any;
3
+ HOST?: string | null | undefined;
4
+ PORT?: string | number | undefined;
5
+ USERNAME?: string | null | undefined;
6
+ PASSWORD?: string | null | undefined;
7
+ DATABASE?: string | null | undefined;
8
+ CONNECTION_LIMIT?: string | number | undefined;
9
+ QUEUE_LIMIT?: string | number | undefined;
10
+ TIMEOUT?: string | number | undefined;
11
+ CHARSET?: string | null | undefined;
12
+ CONNECTION_ERROR?: string | boolean | undefined;
13
+ WAIT_FOR_CONNECTIONS?: string | boolean | undefined;
14
+ DATE_STRINGS?: string | boolean | undefined;
15
+ KEEP_ALIVE_DELAY?: string | number | undefined;
16
+ ENABLE_KEEP_ALIVE?: string | boolean | undefined;
17
+ MULTIPLE_STATEMENTS?: string | boolean | undefined;
18
+ }>;
1
19
  declare const _default: Readonly<{
2
20
  [x: string]: any;
3
21
  HOST?: string | null | undefined;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadOptionsEnvironment = void 0;
6
7
  const dotenv_1 = __importDefault(require("dotenv"));
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const fs_1 = __importDefault(require("fs"));
@@ -46,4 +47,37 @@ for (const [key, value] of Object.entries(env)) {
46
47
  if (/^[0-9]+$/.test(value))
47
48
  env[key] = +value;
48
49
  }
50
+ const loadOptionsEnvironment = () => {
51
+ const environment = () => {
52
+ var _a;
53
+ const NODE_ENV = (_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV;
54
+ const env = path_1.default.join(path_1.default.resolve(), '.env');
55
+ if (NODE_ENV == null)
56
+ return env;
57
+ const envWithEnviroment = path_1.default.join(path_1.default.resolve(), `.env.${NODE_ENV}`);
58
+ if (fs_1.default.existsSync(envWithEnviroment))
59
+ return envWithEnviroment;
60
+ return env;
61
+ };
62
+ const ENV = dotenv_1.default.config({ path: environment() }).parsed;
63
+ const env = {
64
+ host: (ENV === null || ENV === void 0 ? void 0 : ENV.DB_HOST) || (ENV === null || ENV === void 0 ? void 0 : ENV.TSPACE_HOST),
65
+ port: (ENV === null || ENV === void 0 ? void 0 : ENV.DB_PORT) || (ENV === null || ENV === void 0 ? void 0 : ENV.TSPACE_PORT) || 3306,
66
+ username: (ENV === null || ENV === void 0 ? void 0 : ENV.DB_USERNAME) || (ENV === null || ENV === void 0 ? void 0 : ENV.TSPACE_USERNAME),
67
+ password: (ENV === null || ENV === void 0 ? void 0 : ENV.DB_PASSWORD) || (ENV === null || ENV === void 0 ? void 0 : ENV.TSPACE_PASSWORD) || '',
68
+ database: (ENV === null || ENV === void 0 ? void 0 : ENV.DB_DATABASE) || (ENV === null || ENV === void 0 ? void 0 : ENV.TSPACE_DATABASE),
69
+ };
70
+ for (const [key, value] of Object.entries(env)) {
71
+ if (value == null)
72
+ continue;
73
+ if (typeof value === 'string' && ['true', 'false'].some(v => value.toLowerCase() === v)) {
74
+ env[key] = JSON.parse(value.toLowerCase());
75
+ continue;
76
+ }
77
+ if (/^[0-9]+$/.test(value))
78
+ env[key] = +value;
79
+ }
80
+ return Object.freeze(Object.assign({}, env));
81
+ };
82
+ exports.loadOptionsEnvironment = loadOptionsEnvironment;
49
83
  exports.default = Object.freeze(Object.assign({}, env));
@@ -27,12 +27,24 @@ declare class Blueprint {
27
27
  * @return {this} this
28
28
  */
29
29
  tinyInt(number?: number): this;
30
+ /**
31
+ * Assign type 'TINYINT' in table
32
+ * @param {number} number
33
+ * @return {this} this
34
+ */
35
+ tinyint(number?: number): this;
30
36
  /**
31
37
  * Assign type 'BIGINT' in table
32
38
  * @param {number} number [number = 10]
33
39
  * @return {this} this
34
40
  */
35
41
  bigInt(number?: number): this;
42
+ /**
43
+ * Assign type 'BIGINT' in table
44
+ * @param {number} number [number = 10]
45
+ * @return {this} this
46
+ */
47
+ bigint(number?: number): this;
36
48
  /**
37
49
  * Assign type 'DOUBLE' in table
38
50
  * @param {number} length between 1-255
@@ -64,17 +76,33 @@ declare class Blueprint {
64
76
  * @return {this} this
65
77
  */
66
78
  longText(): this;
79
+ /**
80
+ * Assign type 'LONGTEXT' in table
81
+ * @return {this} this
82
+ */
83
+ longtext(): this;
67
84
  /**
68
85
  * Assign type 'MEDIUMTEXT' in table
69
86
  * @return {this} this
70
87
  */
71
88
  mediumText(): this;
89
+ /**
90
+ * Assign type 'MEDIUMTEXT' in table
91
+ * @return {this} this
92
+ */
93
+ mediumtext(): this;
72
94
  /**
73
95
  * Assign type 'TINYTEXT' in table
74
96
  * @param {number} length [length = 1] length of string
75
97
  * @return {this} this
76
98
  */
77
99
  tinyText(): this;
100
+ /**
101
+ * Assign type 'TINYTEXT' in table
102
+ * @param {number} length [length = 1] length of string
103
+ * @return {this} this
104
+ */
105
+ tinytext(): this;
78
106
  /**
79
107
  * Assign type 'TEXT' in table
80
108
  * @param {number} length [length = 1] length of string
@@ -143,6 +171,11 @@ declare class Blueprint {
143
171
  * @return {this} this
144
172
  */
145
173
  currentTimestamp(): this;
174
+ /**
175
+ * Assign attributes 'default currentTimestamp' in table
176
+ * @return {this} this
177
+ */
178
+ currenttimestamp(): this;
146
179
  /**
147
180
  * Assign attributes 'autoIncrement' in table
148
181
  * @return {this} this
@@ -40,6 +40,16 @@ class Blueprint {
40
40
  this.valueType = Number;
41
41
  return this;
42
42
  }
43
+ /**
44
+ * Assign type 'TINYINT' in table
45
+ * @param {number} number
46
+ * @return {this} this
47
+ */
48
+ tinyint(number = 1) {
49
+ this._addAssignType(`TINYINT(${number})`);
50
+ this.valueType = Number;
51
+ return this;
52
+ }
43
53
  /**
44
54
  * Assign type 'BIGINT' in table
45
55
  * @param {number} number [number = 10]
@@ -50,6 +60,16 @@ class Blueprint {
50
60
  this.valueType = Number;
51
61
  return this;
52
62
  }
63
+ /**
64
+ * Assign type 'BIGINT' in table
65
+ * @param {number} number [number = 10]
66
+ * @return {this} this
67
+ */
68
+ bigint(number = 10) {
69
+ this._addAssignType(`BIGINT(${number})`);
70
+ this.valueType = Number;
71
+ return this;
72
+ }
53
73
  /**
54
74
  * Assign type 'DOUBLE' in table
55
75
  * @param {number} length between 1-255
@@ -108,6 +128,14 @@ class Blueprint {
108
128
  this._addAssignType(`LONGTEXT`);
109
129
  return this;
110
130
  }
131
+ /**
132
+ * Assign type 'LONGTEXT' in table
133
+ * @return {this} this
134
+ */
135
+ longtext() {
136
+ this._addAssignType(`LONGTEXT`);
137
+ return this;
138
+ }
111
139
  /**
112
140
  * Assign type 'MEDIUMTEXT' in table
113
141
  * @return {this} this
@@ -116,6 +144,14 @@ class Blueprint {
116
144
  this._addAssignType(`MEDIUMTEXT`);
117
145
  return this;
118
146
  }
147
+ /**
148
+ * Assign type 'MEDIUMTEXT' in table
149
+ * @return {this} this
150
+ */
151
+ mediumtext() {
152
+ this._addAssignType(`MEDIUMTEXT`);
153
+ return this;
154
+ }
119
155
  /**
120
156
  * Assign type 'TINYTEXT' in table
121
157
  * @param {number} length [length = 1] length of string
@@ -125,6 +161,15 @@ class Blueprint {
125
161
  this._addAssignType(`TINYTEXT`);
126
162
  return this;
127
163
  }
164
+ /**
165
+ * Assign type 'TINYTEXT' in table
166
+ * @param {number} length [length = 1] length of string
167
+ * @return {this} this
168
+ */
169
+ tinytext() {
170
+ this._addAssignType(`TINYTEXT`);
171
+ return this;
172
+ }
128
173
  /**
129
174
  * Assign type 'TEXT' in table
130
175
  * @param {number} length [length = 1] length of string
@@ -236,6 +281,14 @@ class Blueprint {
236
281
  this._addAssignAttribute(`DEFAULT CURRENT_TIMESTAMP`);
237
282
  return this;
238
283
  }
284
+ /**
285
+ * Assign attributes 'default currentTimestamp' in table
286
+ * @return {this} this
287
+ */
288
+ currenttimestamp() {
289
+ this._addAssignAttribute(`DEFAULT CURRENT_TIMESTAMP`);
290
+ return this;
291
+ }
239
292
  /**
240
293
  * Assign attributes 'autoIncrement' in table
241
294
  * @return {this} this
@@ -563,6 +563,12 @@ declare class Builder extends AbstractBuilder {
563
563
  * @return {this} this
564
564
  */
565
565
  connection(options: ConnectionOptions): this;
566
+ /**
567
+ *
568
+ * @param {string} env load environment using with command line arguments
569
+ * @return {this} this
570
+ */
571
+ loadEnv(env?: string): this;
566
572
  /**
567
573
  *
568
574
  * @param {Function} pool pool connection database
@@ -1363,6 +1363,25 @@ class Builder extends AbstractBuilder_1.AbstractBuilder {
1363
1363
  this.$pool.set(pool.connection());
1364
1364
  return this;
1365
1365
  }
1366
+ /**
1367
+ *
1368
+ * @param {string} env load environment using with command line arguments
1369
+ * @return {this} this
1370
+ */
1371
+ loadEnv(env) {
1372
+ if (env === null)
1373
+ return this;
1374
+ const options = (0, connection_1.loadOptionsEnvironment)();
1375
+ const pool = new connection_1.PoolConnection({
1376
+ host: String(options.host),
1377
+ port: Number(options.port),
1378
+ database: String(options.database),
1379
+ user: String(options.username),
1380
+ password: String(options.password)
1381
+ });
1382
+ this.$pool.set(pool.connection());
1383
+ return this;
1384
+ }
1366
1385
  /**
1367
1386
  *
1368
1387
  * @param {Function} pool pool connection database
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tspace-mysql",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "mysql query builder object relational mapping",
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.ts",