tspace-mysql 1.1.4 → 1.1.6

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
@@ -3,7 +3,7 @@
3
3
  [![NPM version](https://img.shields.io/npm/v/tspace-mysql.svg)](https://www.npmjs.com)
4
4
  [![NPM downloads](https://img.shields.io/npm/dm/tspace-mysql.svg)](https://www.npmjs.com)
5
5
 
6
- tspace-mysql is an ORM that can run in NodeJs and can be used with TypeScript.
6
+ Tspace-mysql is an ORM that can run in NodeJs and can be used with TypeScript.
7
7
  Its always support the latest TypeScript and JavaScript features and provide additional features that help you to develop.
8
8
 
9
9
  ## Install
@@ -24,7 +24,7 @@ npm install tspace-mysql --save
24
24
  - [Relationships](#relationships)
25
25
  - [One To One](#one-to-one)
26
26
  - [One To Many](#one-to-many)
27
- - [One To One & One To Many (Inverse) / Belongs To](#inverse-belongs-to)
27
+ - [Belongs To](#belongs-to)
28
28
  - [Many To Many](#many-to-many)
29
29
  - [Query Builder](#query-builder)
30
30
  - [Cli](#cli)
@@ -207,7 +207,7 @@ Backup database, you may backup is this:
207
207
  * @param conection defalut current connection
208
208
  */
209
209
  const backup = await new DB().backup({
210
- database: 'try-to-backup',
210
+ database: 'try-to-backup', // clone current database to this
211
211
  connection ?: {
212
212
  host: 'localhost',
213
213
  port : 3306,
@@ -240,9 +240,18 @@ const backupToFile = await new DB().backupToFile({
240
240
  To get started, let's install npm install tspace-mysql -g
241
241
  you may use the make:model command to generate a new model:
242
242
 
243
- ```sh
243
+ ```js
244
+ /**
245
+ *
246
+ * @install global command
247
+ */
244
248
  npm install tspace-mysql -g
245
- tspace-mysql make:model <model name> --dir=<directory>
249
+
250
+ /**
251
+ *
252
+ * @make Model
253
+ */
254
+ tspace-mysql make:model <model name> --dir=< directory >
246
255
 
247
256
  # tspace-mysql make:model User --dir=App/Models
248
257
  # => App/Models/User.ts
@@ -346,7 +355,8 @@ const postsUsingFunction = await new Post().comments().findOne()
346
355
  // postsUsingFunction?.comments => [{...}]
347
356
  ```
348
357
 
349
- ## One To One & One To Many (Inverse) / Belongs To
358
+ ## Belongs To
359
+ A belongsto relationship is used to define relationships where a single model is the child to parent models.
350
360
  ```js
351
361
  import { Model } from 'tspace-mysql'
352
362
  import User from '../User'
@@ -419,7 +429,7 @@ const userUsingFunction = await new User().roles().findOne()
419
429
  // user?.roles => [{...}]
420
430
  ```
421
431
  ## Query Builder
422
- method chaining for queries
432
+ Methods builder for queries
423
433
  ```js
424
434
  where(column , operator , value)
425
435
  whereSensitive(column , operator , value)
@@ -468,17 +478,17 @@ belongsToMany({ name , model , localKey , foreignKey , freezeTable , as })
468
478
  */
469
479
  relations(name1 , name2,...nameN)
470
480
  /**
471
- * @relation using registry in your models. if exists child data remove this parent data
481
+ * @relation using registry in your models. if exists child data remove this data
472
482
  */
473
483
  relationsExists(name1 , name2,...nameN)
474
484
  /**
475
- * @relation call a relation in registry, callback query of parent data
485
+ * @relation call a name of relation in registry, callback query of data
476
486
  */
477
- relationQuery(name,(callback))
487
+ relationQuery(name, (callback) )
478
488
 
479
489
  /**
480
490
  * queries statements
481
- * @execute data statements
491
+ * @execute data of statements
482
492
  */
483
493
  findMany()
484
494
  findOne()
@@ -505,54 +515,79 @@ you may use a basic cli :
505
515
 
506
516
  ## Make Model
507
517
  Command will be placed Model in the specific directory
508
- ```sh
509
- tspace-mysql make:model <MODEL NAME> --m --dir=.... --type=....
518
+ ```js
519
+
510
520
  /**
521
+ *
522
+ * @make Model
511
523
  * @options
512
- * --m // created scheme table for migrate
513
- * --dir=directory // created model in directory
514
- * --type=js // extension js default ts
524
+ * @arg --m => created scheme table for migrate. short cut migration table like Make Migration
525
+ * @arg --dir=directory => created model in directory. default root directory
526
+ * @arg --type=js // extension js. default ts
515
527
  */
528
+ tspace-mysql make:model <model name> --m --dir=.... --type=....
516
529
 
517
530
  tspace-mysql make:model User --m --dir=app/Models
518
- // =>
531
+ /**
532
+ *
533
+ * @Ex directory
534
+ */
519
535
  - node_modules
520
536
  - app
521
537
  - Models
522
538
  User.ts
523
- */
524
539
  ```
525
540
 
526
541
  ## Make Migration
527
542
  Command will be placed Migration in the specific directory
528
- ```sh
529
- tspace-mysql make:migration <TABLE NAME>
530
- /**
543
+ ```js
544
+ /**
545
+ *
546
+ * @make Migration Table
531
547
  * @options
532
- * --type=js /* extension js default ts */
533
- * --dir=directory /* created table in directory */
548
+ * @arg --dir=directory => created scheme table in directory. default root directory
549
+ * @arg --type=js // extension js default ts
534
550
  */
551
+ tspace-mysql make:migration <table name> --type=... --dir=....
552
+
535
553
  tspace-mysql make:migration users --dir=app/Models/Migrations
536
- // =>
554
+ /**
555
+ *
556
+ * @Ex directory
557
+ */
537
558
  - node_modules
538
559
  - app
539
560
  - Models
540
561
  - Migrations
541
562
  create_users_table.ts
542
563
  User.ts
543
- */
544
564
  ```
545
565
  ## Migrate
546
- ```sh
547
- tspace-mysql migrate <FOLDER> --type=...
548
- /**
566
+ ```js
567
+ /**
568
+ *
569
+ * @run Migrate table
549
570
  * @options
550
- *--type=js /* extension js default ts */
551
- *--dir=directory /* find migrate in directory */
571
+ * @arg --dir=directory => find migrate in directory. default find in root folder
572
+ * @arg --type=js // extension js default ts
552
573
  */
553
-
554
- tspace-mysql migrate --dir=App/Models/Migrations
555
- // => migrate all schema table in folder into database
574
+ tspace-mysql migrate <folder> --type=... --dir=....
575
+
576
+ tspace-mysql migrate --dir=App/Models/Migrations --type=js
577
+
578
+ /**
579
+ *
580
+ * @Ex directory
581
+ */
582
+ - node_modules
583
+ - app
584
+ - Models
585
+ - Migrations
586
+ create_users_table.ts
587
+ create_posts_table.ts
588
+ User.ts
589
+ Post.ts
590
+ // => migrate all schemas in folder <Migrations>. created into database
556
591
  ```
557
592
 
558
593
  ## Blueprint
@@ -562,8 +597,9 @@ import { Schema , Blueprint , DB } from 'tspace-mysql'
562
597
  (async () => {
563
598
  await new Schema().table('users',{
564
599
  id : new Blueprint().int().notNull().primary().autoIncrement(),
565
- name : new Blueprint().varchar(120).default('my name'),
566
- email : new Blueprint().varchar(255).unique(),
600
+ uuid : new Blueprint().varchar(120).null()
601
+ name : new Blueprint().varchar(120).default('name'),
602
+ email : new Blueprint().varchar(255).unique().notNull(),
567
603
  email_verify : new Blueprint().tinyInt(),
568
604
  password : new Blueprint().varchar(255),
569
605
  created_at : new Blueprint().null().timestamp(),
@@ -577,7 +613,7 @@ import { Schema , Blueprint , DB } from 'tspace-mysql'
577
613
  })()
578
614
 
579
615
  /**
580
- *
616
+ * type of schema in database
581
617
  * @Types
582
618
  *
583
619
  */
@@ -598,7 +634,7 @@ dateTime()
598
634
  timestamp ()
599
635
 
600
636
  /**
601
- *
637
+ * attrbuites of schema in database
602
638
  * @Attrbuites
603
639
  *
604
640
  */
package/dist/cli/index.js CHANGED
@@ -3,37 +3,36 @@
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
7
6
  Object.defineProperty(exports, "__esModule", { value: true });
8
- var fs_1 = __importDefault(require("fs"));
9
- var make_1 = __importDefault(require("./models/make"));
10
- var make_2 = __importDefault(require("./tables/make"));
11
- var make_3 = __importDefault(require("./migrate/make"));
12
- var commands = {
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const make_1 = __importDefault(require("./models/make"));
9
+ const make_2 = __importDefault(require("./tables/make"));
10
+ const make_3 = __importDefault(require("./migrate/make"));
11
+ const commands = {
13
12
  'make:model': make_1.default,
14
13
  'make:table': make_2.default,
15
14
  'make:migration': make_2.default,
16
15
  'migrate': make_3.default
17
16
  };
18
17
  try {
19
- var name = (_c = (_b = (_a = process.argv.slice(2)) === null || _a === void 0 ? void 0 : _a.find(function (data) {
20
- return data === null || data === void 0 ? void 0 : data.includes('--name=');
21
- })) === null || _b === void 0 ? void 0 : _b.replace('--name=', '')) !== null && _c !== void 0 ? _c : null;
22
- var migrate = (_e = (_d = process.argv.slice(2)) === null || _d === void 0 ? void 0 : _d.includes('--m')) !== null && _e !== void 0 ? _e : false;
23
- var dir = (_h = (_g = (_f = process.argv.slice(2)) === null || _f === void 0 ? void 0 : _f.find(function (data) {
24
- return data === null || data === void 0 ? void 0 : data.includes('--dir=');
25
- })) === null || _g === void 0 ? void 0 : _g.replace('--dir=', '/')) !== null && _h !== void 0 ? _h : null;
26
- var type = (_l = (_k = (_j = process.argv.slice(2)) === null || _j === void 0 ? void 0 : _j.find(function (data) {
27
- return data === null || data === void 0 ? void 0 : data.includes('--type=');
28
- })) === null || _k === void 0 ? void 0 : _k.replace('--type=', '.')) !== null && _l !== void 0 ? _l : '.ts';
18
+ const name = process.argv.slice(2)?.find(data => {
19
+ return data?.includes('--name=');
20
+ })?.replace('--name=', '') ?? null;
21
+ const migrate = process.argv.slice(2)?.includes('--m') ?? false;
22
+ const dir = process.argv.slice(2)?.find(data => {
23
+ return data?.includes('--dir=');
24
+ })?.replace('--dir=', '/') ?? null;
25
+ let type = process.argv.slice(2)?.find(data => {
26
+ return data?.includes('--type=');
27
+ })?.replace('--type=', '.') ?? '.ts';
29
28
  type = ['.js', '.ts'].includes(type) ? type : '.ts';
30
- var file = (_o = (_m = process.argv.slice(3)) === null || _m === void 0 ? void 0 : _m.shift()) !== null && _o !== void 0 ? _o : '';
31
- var cmd = {
32
- name: name,
33
- file: file,
34
- dir: dir,
35
- migrate: migrate,
36
- type: type,
29
+ const file = process.argv.slice(3)?.shift() ?? '';
30
+ const cmd = {
31
+ name,
32
+ file,
33
+ dir,
34
+ migrate,
35
+ type,
37
36
  cwd: process.cwd(),
38
37
  fs: fs_1.default,
39
38
  npm: 'tspace-mysql'
@@ -41,5 +40,5 @@ try {
41
40
  commands[process.argv[2]](cmd);
42
41
  }
43
42
  catch (err) {
44
- console.log("readme https://www.npmjs.com/package/tspace-mysql");
43
+ console.log(`readme https://www.npmjs.com/package/tspace-mysql`);
45
44
  }
@@ -1,52 +1,29 @@
1
1
  "use strict";
2
- var __values = (this && this.__values) || function(o) {
3
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
- if (m) return m.call(o);
5
- if (o && typeof o.length === "number") return {
6
- next: function () {
7
- if (o && i >= o.length) o = void 0;
8
- return { value: o && o[i++], done: !o };
9
- }
10
- };
11
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
- var child_process_1 = require("child_process");
15
- exports.default = (function (formCommand) {
16
- var e_1, _a;
17
- var _b, _c, _d;
18
- var type = formCommand.type, dir = formCommand.dir, cwd = formCommand.cwd, fs = formCommand.fs;
3
+ const child_process_1 = require("child_process");
4
+ exports.default = (formCommand) => {
5
+ const { type, dir, cwd, fs } = formCommand;
19
6
  try {
20
7
  if (dir == null)
21
8
  throw new Error('Not found directory');
22
- var path = "".concat(cwd, "/").concat(dir);
23
- var files = (_b = fs.readdirSync(path)) !== null && _b !== void 0 ? _b : [];
24
- if (!(files === null || files === void 0 ? void 0 : files.length))
9
+ const path = `${cwd}/${dir}`;
10
+ const files = fs.readdirSync(path) ?? [];
11
+ if (!files?.length)
25
12
  console.log('this folder is empty');
26
- var cmd = type === '.js' ? 'node' : 'ts-node';
27
- try {
28
- for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
29
- var _file = files_1_1.value;
30
- var run = (0, child_process_1.exec)("".concat(cmd, " ").concat(path, "/").concat(_file));
31
- (_c = run === null || run === void 0 ? void 0 : run.stdout) === null || _c === void 0 ? void 0 : _c.on('data', function (data) {
32
- if (data)
33
- console.log(data);
34
- });
35
- (_d = run === null || run === void 0 ? void 0 : run.stderr) === null || _d === void 0 ? void 0 : _d.on('data', function (err) {
36
- if (err)
37
- console.error(err);
38
- });
39
- }
40
- }
41
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
42
- finally {
43
- try {
44
- if (files_1_1 && !files_1_1.done && (_a = files_1.return)) _a.call(files_1);
45
- }
46
- finally { if (e_1) throw e_1.error; }
13
+ const cmd = type === '.js' ? 'node' : 'ts-node';
14
+ for (const _file of files) {
15
+ const run = (0, child_process_1.exec)(`${cmd} ${path}/${_file}`);
16
+ run?.stdout?.on('data', (data) => {
17
+ if (data)
18
+ console.log(data);
19
+ });
20
+ run?.stderr?.on('data', (err) => {
21
+ if (err)
22
+ console.error(err);
23
+ });
47
24
  }
48
25
  }
49
26
  catch (err) {
50
27
  console.log(err.message);
51
28
  }
52
- });
29
+ };
@@ -3,33 +3,33 @@ 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
- var model_1 = __importDefault(require("./model"));
7
- var table_1 = __importDefault(require("../tables/table"));
8
- var pluralize_1 = __importDefault(require("pluralize"));
9
- exports.default = (function (formCommand) {
10
- var file = formCommand.file, migrate = formCommand.migrate, dir = formCommand.dir, type = formCommand.type, cwd = formCommand.cwd, fs = formCommand.fs, npm = formCommand.npm;
6
+ const model_1 = __importDefault(require("./model"));
7
+ const table_1 = __importDefault(require("../tables/table"));
8
+ const pluralize_1 = __importDefault(require("pluralize"));
9
+ exports.default = (formCommand) => {
10
+ const { file, migrate, dir, type, cwd, fs, npm } = formCommand;
11
11
  if (dir) {
12
12
  try {
13
- fs.accessSync(cwd + "/".concat(dir), fs.F_OK, {
13
+ fs.accessSync(cwd + `/${dir}`, fs.F_OK, {
14
14
  recursive: true
15
15
  });
16
16
  }
17
17
  catch (e) {
18
- fs.mkdirSync(cwd + "/".concat(dir), {
18
+ fs.mkdirSync(cwd + `/${dir}`, {
19
19
  recursive: true
20
20
  });
21
21
  }
22
22
  }
23
- var model = dir ? "".concat(cwd, "/").concat(dir, "/").concat(file).concat(type) : "".concat(cwd, "/").concat(file).concat(type);
24
- var data = (0, model_1.default)(file, npm);
25
- fs.writeFile(model, data, function (err) {
23
+ const model = dir ? `${cwd}/${dir}/${file}${type}` : `${cwd}/${file}${type}`;
24
+ const data = (0, model_1.default)(file, npm);
25
+ fs.writeFile(model, data, (err) => {
26
26
  if (err)
27
27
  throw err.message;
28
28
  });
29
- console.log("Model : '".concat(file, "' created successfully"));
29
+ console.log(`Model : '${file}' created successfully`);
30
30
  if (migrate) {
31
- var tableName = (0, pluralize_1.default)(file.replace(/([A-Z])/g, function (str) { return '_' + str.toLowerCase(); }).slice(1));
32
- var folder = dir ? "".concat(dir, "/Migrations") : "/Migrations";
31
+ const tableName = (0, pluralize_1.default)(file.replace(/([A-Z])/g, (str) => '_' + str.toLowerCase()).slice(1));
32
+ const folder = dir ? `${dir}/Migrations` : `/Migrations`;
33
33
  try {
34
34
  fs.accessSync(cwd + folder, fs.F_OK, {
35
35
  recursive: true
@@ -40,12 +40,12 @@ exports.default = (function (formCommand) {
40
40
  recursive: true
41
41
  });
42
42
  }
43
- var folderMigrate = "".concat(cwd, "/").concat(folder, "/create_").concat(tableName, "_table").concat(type);
44
- var table = (0, table_1.default)(tableName, npm);
45
- fs.writeFile(folderMigrate, table, function (err) {
43
+ const folderMigrate = `${cwd}/${folder}/create_${tableName}_table${type}`;
44
+ const table = (0, table_1.default)(tableName, npm);
45
+ fs.writeFile(folderMigrate, table, (err) => {
46
46
  if (err)
47
47
  throw err;
48
48
  });
49
- console.log("Migration : '".concat(tableName, "' created successfully"));
49
+ console.log(`Migration : '${tableName}' created successfully`);
50
50
  }
51
- });
51
+ };
@@ -1,6 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var Model = function (model, npm) {
4
- return "import { Model } from '".concat(npm, "'\nclass ").concat(model, " extends Model {\n constructor(){\n super()\n /**\n * \n * Assign setting global in your model\n * @useMethod\n *\n * this.useDebug() // => runing a uuid (universally unique identifier) when insert new data\n * this.usePrimaryKey('id') // => runing a uuid (universally unique identifier) when insert new data\n * this.useTimestamp({ createdAt : 'created_at' , updatedAt : 'updated_at' }) // runing a timestamp when insert or update\n * this.useSoftDelete()\n * this.useDisableSoftDeleteInRelations()\n * this.useTable('Users')\n * this.useTableSingular()\n * this.useTablePlural()\n * this.usePattern('snake_case') \n * this.useUUID('uuid')\n * this.useRegistry()\n */\n }\n}\nexport { ").concat(model, " }\nexport default ").concat(model, "\n");
3
+ const Model = (model, npm) => {
4
+ return `import { Model } from '${npm}'
5
+ class ${model} extends Model {
6
+ constructor(){
7
+ super()
8
+ /**
9
+ *
10
+ * Assign setting global in your model
11
+ * @useMethod
12
+ *
13
+ * this.useDebug() // => runing a uuid (universally unique identifier) when insert new data
14
+ * this.usePrimaryKey('id') // => runing a uuid (universally unique identifier) when insert new data
15
+ * this.useTimestamp({ createdAt : 'created_at' , updatedAt : 'updated_at' }) // runing a timestamp when insert or update
16
+ * this.useSoftDelete()
17
+ * this.useDisableSoftDeleteInRelations()
18
+ * this.useTable('Users')
19
+ * this.useTableSingular()
20
+ * this.useTablePlural()
21
+ * this.usePattern('snake_case')
22
+ * this.useUUID('uuid')
23
+ * this.useRegistry()
24
+ */
25
+ }
26
+ }
27
+ export { ${model} }
28
+ export default ${model}
29
+ `;
5
30
  };
6
31
  exports.default = Model;
@@ -3,24 +3,24 @@ 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
- var table_1 = __importDefault(require("./table"));
7
- exports.default = (function (formCommand) {
8
- var file = formCommand.file, type = formCommand.type, cwd = formCommand.cwd, dir = formCommand.dir, fs = formCommand.fs, npm = formCommand.npm;
6
+ const table_1 = __importDefault(require("./table"));
7
+ exports.default = (formCommand) => {
8
+ const { file, type, cwd, dir, fs, npm } = formCommand;
9
9
  try {
10
- fs.accessSync(cwd + "/".concat(file), fs.F_OK, {
10
+ fs.accessSync(cwd + `/${file}`, fs.F_OK, {
11
11
  recursive: true
12
12
  });
13
13
  }
14
14
  catch (e) {
15
- fs.mkdirSync(cwd + "/".concat(file), {
15
+ fs.mkdirSync(cwd + `/${file}`, {
16
16
  recursive: true
17
17
  });
18
18
  }
19
- var folderMigrate = dir ? "".concat(cwd, "/").concat(dir, "/create_").concat(file, "_table").concat(type) : "".concat(cwd, "/create_").concat(file, "_table").concat(type);
20
- var table = (0, table_1.default)(file, npm);
21
- fs.writeFile(folderMigrate, table, function (err) {
19
+ const folderMigrate = dir ? `${cwd}/${dir}/create_${file}_table${type}` : `${cwd}/create_${file}_table${type}`;
20
+ const table = (0, table_1.default)(file, npm);
21
+ fs.writeFile(folderMigrate, table, (err) => {
22
22
  if (err)
23
23
  console.log(err.message);
24
24
  });
25
- console.log("Migration : ".concat(file, " created successfully"));
26
- });
25
+ console.log(`Migration : ${file} created successfully`);
26
+ };
@@ -1,6 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var Table = function (table, npm) {
4
- return "import { Schema , Blueprint , DB } from '".concat(npm, "'\n(async () => {\n await new Schema().table('").concat(table, "',{ \n id : new Blueprint().int().notNull().primary().autoIncrement(),\n uuid : new Blueprint().varchar(50),\n name : new Blueprint().varchar(120).default('my name'),\n email : new Blueprint().varchar(120).unique(),\n email_verify : new Blueprint().tinyInt(),\n password : new Blueprint().varchar(120),\n birthdate : new Blueprint().date(),\n created_at : new Blueprint().null().timestamp(),\n updated_at : new Blueprint().null().timestamp()\n })\n\n /**\n * \n * @Faker data\n * await new DB().table('").concat(table, "').faker(5)\n */\n})()\n");
3
+ const Table = (table, npm) => {
4
+ return `import { Schema , Blueprint , DB } from '${npm}'
5
+ (async () => {
6
+ await new Schema().table('${table}',{
7
+ id : new Blueprint().int().notNull().primary().autoIncrement(),
8
+ uuid : new Blueprint().varchar(50).null(),
9
+ name : new Blueprint().varchar(120).default('my name'),
10
+ email : new Blueprint().varchar(120).unique(),
11
+ email_verify : new Blueprint().tinyInt(),
12
+ password : new Blueprint().varchar(120),
13
+ birthdate : new Blueprint().date(),
14
+ created_at : new Blueprint().null().timestamp(),
15
+ updated_at : new Blueprint().null().timestamp()
16
+ })
17
+
18
+ /**
19
+ *
20
+ * @Faker data
21
+ * await new DB().table('${table}').faker(5)
22
+ */
23
+ })()
24
+ `;
5
25
  };
6
26
  exports.default = Table;
@@ -4,11 +4,10 @@ declare const env: Readonly<{
4
4
  DB_USERNAME: string | undefined;
5
5
  DB_PASSWORD: string | undefined;
6
6
  DB_DATABASE: string | undefined;
7
- TSPACE_MYSQL_HOST: string | undefined;
8
- TSPACE_MYSQL_PORT: string | undefined;
9
- TSPACE_MYSQL_USERNAME: string | undefined;
10
- TSPACE_MYSQL_PASSWORD: string | undefined;
11
- TSPACE_MYSQL_DATABASE: string | undefined;
7
+ DB_CONNECTION_LIMIT: string | undefined;
8
+ DB_DATE_STRING: string | undefined;
9
+ DB_TIMEOUT: string | undefined;
10
+ DB_QUEUE_LIMIT: string | undefined;
12
11
  }>;
13
12
  export { env };
14
13
  export default env;
@@ -4,14 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.env = void 0;
7
- var dotenv_1 = __importDefault(require("dotenv"));
8
- var path_1 = __importDefault(require("path"));
9
- var fs_1 = __importDefault(require("fs"));
10
- var environment = function () {
11
- var _a;
12
- var NODE_ENV = (_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV;
13
- var envWithoutEnviroment = path_1.default.join(path_1.default.resolve(), '.env');
14
- var envWithEnviroment = path_1.default.join(path_1.default.resolve(), ".env.".concat(NODE_ENV));
7
+ const dotenv_1 = __importDefault(require("dotenv"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const environment = () => {
11
+ const NODE_ENV = process.env?.NODE_ENV;
12
+ const envWithoutEnviroment = path_1.default.join(path_1.default.resolve(), '.env');
13
+ const envWithEnviroment = path_1.default.join(path_1.default.resolve(), `.env.${NODE_ENV}`);
15
14
  if (NODE_ENV == null)
16
15
  return envWithoutEnviroment;
17
16
  if (fs_1.default.existsSync(envWithEnviroment))
@@ -19,17 +18,16 @@ var environment = function () {
19
18
  return envWithoutEnviroment;
20
19
  };
21
20
  dotenv_1.default.config({ path: environment() });
22
- var env = Object.freeze({
21
+ const env = Object.freeze({
23
22
  DB_HOST: process.env.DB_HOST,
24
23
  DB_PORT: process.env.DB_PORT,
25
24
  DB_USERNAME: process.env.DB_USERNAME,
26
25
  DB_PASSWORD: process.env.DB_PASSWORD,
27
26
  DB_DATABASE: process.env.DB_DATABASE,
28
- TSPACE_MYSQL_HOST: process.env.TSPACE_MYSQL_HOST,
29
- TSPACE_MYSQL_PORT: process.env.TSPACE_MYSQL_PORT,
30
- TSPACE_MYSQL_USERNAME: process.env.TSPACE_MYSQL_USERNAME,
31
- TSPACE_MYSQL_PASSWORD: process.env.TSPACE_MYSQL_PASSWORD,
32
- TSPACE_MYSQL_DATABASE: process.env.TSPACE_MYSQL_DATABASE
27
+ DB_CONNECTION_LIMIT: process.env.DB_CONNECTION_LIMIT,
28
+ DB_DATE_STRING: process.env.DB_DATE_STRING,
29
+ DB_TIMEOUT: process.env.DB_TIMEOUT,
30
+ DB_QUEUE_LIMIT: process.env.DB_QUEUE_LIMIT
33
31
  });
34
32
  exports.env = env;
35
33
  exports.default = env;