tspace-mysql 1.1.8 → 1.2.0

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.
Files changed (36) hide show
  1. package/README.md +115 -38
  2. package/dist/cli/generate/make.d.ts +4 -0
  3. package/dist/cli/generate/make.js +45 -0
  4. package/dist/cli/index.js +27 -13
  5. package/dist/cli/migrate/make.js +5 -4
  6. package/dist/cli/models/make.d.ts +1 -1
  7. package/dist/cli/models/make.js +2 -2
  8. package/dist/cli/models/model.js +3 -4
  9. package/dist/cli/query/index.d.ts +4 -0
  10. package/dist/cli/query/index.js +7 -0
  11. package/dist/lib/connection/index.d.ts +8 -32
  12. package/dist/lib/connection/index.js +50 -37
  13. package/dist/lib/connection/options.d.ts +4 -0
  14. package/dist/lib/{config/env.js → connection/options.js} +10 -7
  15. package/dist/lib/constants/index.d.ts +2 -2
  16. package/dist/lib/constants/index.js +14 -11
  17. package/dist/lib/tspace/AbstractDB.d.ts +2 -0
  18. package/dist/lib/tspace/AbstractDatabase.d.ts +23 -19
  19. package/dist/lib/tspace/AbstractDatabase.js +29 -26
  20. package/dist/lib/tspace/AbstractModel.d.ts +5 -4
  21. package/dist/lib/tspace/Blueprint.js +4 -2
  22. package/dist/lib/tspace/DB.d.ts +23 -2
  23. package/dist/lib/tspace/DB.js +93 -30
  24. package/dist/lib/tspace/Database.d.ts +26 -13
  25. package/dist/lib/tspace/Database.js +920 -777
  26. package/dist/lib/tspace/Interface.d.ts +26 -0
  27. package/dist/lib/tspace/Logger.js +5 -4
  28. package/dist/lib/tspace/Model.d.ts +73 -23
  29. package/dist/lib/tspace/Model.js +1208 -867
  30. package/dist/lib/tspace/ProxyHandler.d.ts +9 -1
  31. package/dist/lib/tspace/ProxyHandler.js +8 -9
  32. package/dist/lib/tspace/Schema.js +35 -22
  33. package/dist/lib/utils/index.d.ts +0 -1
  34. package/dist/lib/utils/index.js +15 -44
  35. package/package.json +4 -2
  36. package/dist/lib/config/env.d.ts +0 -4
package/README.md CHANGED
@@ -15,7 +15,7 @@ npm install tspace-mysql --save
15
15
  ```
16
16
  ## Basic Usage
17
17
  - [Configuration](#configuration)
18
- - [Running Queries](#running-queryies)
18
+ - [Running Queries](#running-queries)
19
19
  - [Database Transactions](#database-transactions)
20
20
  - [Connection](#connection)
21
21
  - [Backup](#backup)
@@ -32,23 +32,25 @@ npm install tspace-mysql --save
32
32
  - [Make Model](#make-model)
33
33
  - [Make Migration](#make-migration)
34
34
  - [Migrate](#migrate)
35
+ - [Query](#query)
36
+ - [Menerate Models](#generate-models)
35
37
  - [Blueprint](#blueprint)
36
38
 
37
39
  ## Configuration
38
40
  Created your environment variables is to use a .env file, you may establish a connection is this:
39
41
  ```js
40
- TSPACE_HOST = localhost
41
- TSPACE_PORT = 3306
42
- TSPACE_USERNAME = root
43
- TSPACE_PASSWORD = password
44
- TSPACE_DATABASE = database
42
+ DB_HOST = localhost
43
+ DB_PORT = 3306
44
+ DB_USERNAME = root
45
+ DB_PASSWORD = password
46
+ DB_DATABASE = database
45
47
 
46
48
  /** default
47
- TSPACE_CONNECTION_LIMIT = 10
48
- TSPACE_CONNECTION_ERROR = true
49
- TSPACE_QUEUE_LIMIT = 25
50
- TSPACE_TIMEOUT = 30000
51
- TSPACE_DATE_STRINGS = true
49
+ DB_CONNECTION_LIMIT = 30
50
+ DB_CONNECTION_ERROR = true
51
+ DB_QUEUE_LIMIT = 25
52
+ DB_TIMEOUT = 30000
53
+ DB_DATE_STRINGS = true
52
54
  */
53
55
 
54
56
  ```
@@ -64,6 +66,16 @@ Once you have configured your database connection, you may run queries is this :
64
66
  | 2 | tspace2 | tspace2@gmail.com |
65
67
  +-------------+--------------+----------------------------+
66
68
 
69
+
70
+ +-------------+--------------+----------------------------+
71
+ | table posts |
72
+ +-------------+--------------+----------------------------+
73
+ | id | user_id | title |
74
+ |-------------|--------------|----------------------------|
75
+ | 1 | 1 | posts tspace |
76
+ | 2 | 2 | posts tspace2 |
77
+ +-------------+--------------+----------------------------+
78
+
67
79
  import { DB } from 'tspace-mysql'
68
80
  (async () => {
69
81
  await new DB('users').findMany() // SELECT * FROM users => Array
@@ -82,21 +94,45 @@ const selectQueries = await new DB('users').select('id','username').findMany()
82
94
  */
83
95
  await new DB('users').except('id','username').findOne()
84
96
  ```
97
+
98
+ Running A OrderBy & GroupBy Query
99
+ ```js
100
+ await new DB('users').orderBy('id','asc').findOne()
101
+ await new DB('users').orderBy('id','desc').findOne()
102
+ await new DB('users').oldest('id').findOne()
103
+ await new DB('users').latest('id').findOne()
104
+
105
+ await new DB('users').groupBy('id').findOne()
106
+ await new DB('users').groupBy('id','usernamename').findOne()
107
+ ```
108
+
109
+ Running A Join Query
110
+ ```js
111
+ await new DB('posts').join('posts.user_id' , 'users.id').findOne()
112
+ await new DB('posts').leftJoin('posts.user_id' , 'users.id').findOne()
113
+ await new DB('posts').rightJoin('posts.user_id' , 'users.id').findOne()
114
+ ```
115
+
85
116
  Running A Where Query
86
117
  ```js
87
118
  const user = await new DB('users').where('id',1).findOne()
88
119
  // user => { id : 1 , username : 'tspace', email : 'tspace@gmail.com'}
89
120
  const users = await new DB('users').where('id','!=',1).findMany()
90
121
  // users => [{ id : 2 , username : 'tspace2' , email : 'tspace2@gmail.com' }]
91
- /**
92
- * @example where
93
- */
122
+
94
123
  const whereIn = await new DB('users').whereIn('id',[1,2]).findMany()
95
124
  const whereBetween = await new DB('users').whereBetween('id',[1,2]).findMany()
96
125
  const whereSubQuery = await new DB('users').whereSubQuery('id','select id from users').findMany()
97
126
  // await new DB('users').whereSubQuery('id',new DB('users').select('id').toString()).findMany()
98
127
  const whereNull = await new DB('users').whereNull('username').findOne()
99
128
  ```
129
+
130
+ Running A Hook Query
131
+ ```js
132
+ const hookResult = (result) => console.log(result)
133
+ const user = await new DB('users').where('id',1).hook(hookResult).findOne()
134
+ ```
135
+
100
136
  Running A Insert Query
101
137
  ```js
102
138
  const user = await new DB('users')
@@ -131,6 +167,16 @@ const users = await new DB('users')
131
167
  },
132
168
  ]).save()
133
169
 
170
+ const users = await new DB('users')
171
+ .where('name','tspace4')
172
+ .where('email','tspace4@gmail.com')
173
+ .createNotExists({
174
+ name :'tspace4',
175
+ email : 'tspace4@gmail.com'
176
+ })
177
+ .save()
178
+ // if has exists return null, if not exists created new data
179
+
134
180
  ```
135
181
  Running A Update Query
136
182
  ```js
@@ -160,7 +206,7 @@ const user = await new DB('users')
160
206
  name : 'tspace1**',
161
207
  email : 'tspace1@gmail.com'
162
208
  }).save()
163
- // user => { username : 'tspace1**', email : 'tspace1@gmail.com'}
209
+ // user => { username : 'tspace1**', email : 'tspace1@gmail.com' }
164
210
  ```
165
211
 
166
212
  Running A Delete Query
@@ -170,7 +216,7 @@ const deleted = await new DB('users').where('id',1).delete()
170
216
  ```
171
217
  ## Database Transactions
172
218
 
173
- Within a database transaction, you may use the:
219
+ Within a Database Transaction, you may use the:
174
220
 
175
221
  ```js
176
222
  const connection = await new DB().beginTransaction()
@@ -209,7 +255,7 @@ try {
209
255
  title : `tspace-post3`
210
256
  }
211
257
  ])
212
- .bind(connection) /** don't forget this /*
258
+ .bind(connection) // don't forget this
213
259
  .save()
214
260
 
215
261
  /**
@@ -232,14 +278,16 @@ try {
232
278
  ## Connection
233
279
  When establishing a connection, you may establish options is this:
234
280
  ```js
281
+ const connection = await new DB().getConnection({
282
+ host: 'localhost',
283
+ port : 3306,
284
+ database: 'database'
285
+ username: 'username',
286
+ password: 'password',
287
+ })
288
+
235
289
  const users = await new DB('users')
236
- .connection({
237
- host: 'localhost',
238
- port : 3306,
239
- database: 'database'
240
- username: 'username',
241
- password: 'password',
242
- })
290
+ .bind(connection)
243
291
  .findMany()
244
292
  // users => [{ .... }]
245
293
  ```
@@ -312,8 +360,8 @@ class User extends Model {
312
360
  super()
313
361
  this.useTimestamp() /** created_at , updated_at
314
362
  /**
315
- * @custom
316
363
  *
364
+ * @Custom
317
365
  *
318
366
  * this.useTimestamp({
319
367
  * createdAt : 'created_at',
@@ -353,11 +401,12 @@ class User extends Model {
353
401
  this.hasOne({ name : 'phone' , model : Phone })
354
402
  }
355
403
  /**
404
+ * Mark a method for relationship
356
405
  * @hasOne Get the phone associated with the user. using function callback
357
406
  * @function
358
407
  */
359
408
  phone (callback ?: Function) {
360
- return this.hasOneQuery({ name : 'phone' , model : Phone } , callback)
409
+ return this.hasOneBuilder({ name : 'phone' , model : Phone } , callback)
361
410
  }
362
411
  }
363
412
  export default User
@@ -388,11 +437,12 @@ class Post extends Model {
388
437
  this.hasMany({ name : 'comments' , model : Comment })
389
438
  }
390
439
  /**
440
+ *
391
441
  * @hasManyQuery Get the comments for the post. using function callback
392
442
  * @function
393
443
  */
394
444
  comments (callback ?: Function) {
395
- return this.hasManyQuery({ name : 'comments' , model : Comment } , callback)
445
+ return this.hasManyBuilder({ name : 'comments' , model : Comment } , callback)
396
446
  }
397
447
  }
398
448
  export default Post
@@ -423,11 +473,12 @@ class Phone extends Model {
423
473
  this.belognsTo({ name : 'user' , model : User })
424
474
  }
425
475
  /**
476
+ *
426
477
  * @belongsToQuery Get the user that owns the phone.. using function callback
427
478
  * @function
428
479
  */
429
480
  user (callback ?: Function) {
430
- return this.belongsToQuery({ name : 'user' , model : User }, callback)
481
+ return this.belongsToBuilder({ name : 'user' , model : User }, callback)
431
482
  }
432
483
  }
433
484
  export default Phone
@@ -462,7 +513,7 @@ class User extends Model {
462
513
  * @function
463
514
  */
464
515
  roles (callback ?: Function) {
465
- return this.belognsToManyQuery({ model : Role } , callback)
516
+ return this.belognsToManyBuilder({ model : Role } , callback)
466
517
  }
467
518
  }
468
519
  export default User
@@ -529,13 +580,20 @@ whereSensitive(column , operator , value)
529
580
  whereId(id)
530
581
  whereUser(userId)
531
582
  whereEmail(value)
532
- orWhere(column , operator , value)
533
583
  whereIn(column , [])
534
584
  whereNotIn(column , [])
535
585
  whereNull(column)
536
586
  whereNotNull(column)
537
587
  whereBetween (column , [value1 , value2])
588
+ whereQuery(callback)
589
+ whereRaw(sql)
590
+ whereExists(sql)
538
591
  whereSubQuery(colmn , rawSQL)
592
+ whereNotSubQuery(colmn , rawSQL)
593
+ orWhere(column , operator , value)
594
+ orWhereRaw(sql)
595
+ orWhereIn(column , [])
596
+ orWhereSubQuery(colmn , rawSQL)
539
597
  select(column1 ,column2 ,...N)
540
598
  except(column1 ,column2 ,...N)
541
599
  only(column1 ,column2 ,...N)
@@ -557,6 +615,7 @@ updateOrCreate (objects)
557
615
  connection(options)
558
616
  backup({ database , connection })
559
617
  backupToFile({ filePath, database , connection })
618
+ hook((result) => ...) // callback result to function
560
619
 
561
620
  /**
562
621
  * registry relation in your models
@@ -603,9 +662,13 @@ save() /*for action statements insert update or delete */
603
662
  ```
604
663
 
605
664
  ## Cli
606
- To get started, let's install npm install tspace-mysql -g
665
+ To get started, let's install tspace-mysql
607
666
  you may use a basic cli :
608
667
 
668
+ ```sh
669
+ npm install tspace-mysql -g
670
+
671
+ ```
609
672
  ## Make Model
610
673
  Command will be placed Model in the specific directory
611
674
  ```js
@@ -683,6 +746,20 @@ tspace-mysql migrate --dir=App/Models/Migrations --type=js
683
746
  // => migrate all schemas in folder <Migrations>. created into database
684
747
  ```
685
748
 
749
+ # Query
750
+ Command will be execute a query
751
+ ```js
752
+ tspace-mysql query "SELECT * FROM users"
753
+
754
+ ```
755
+
756
+ # Generate Models
757
+ Command will be generate models from table in database
758
+ ```js
759
+ tspace-mysql generate:models
760
+
761
+ ```
762
+
686
763
  ## Blueprint
687
764
  Schema table created by command make:migration, you may use the:
688
765
  ```js
@@ -731,12 +808,12 @@ timestamp ()
731
808
  * @Attrbuites
732
809
  *
733
810
  */
734
- unsigned ()
735
- unique ()
736
- null ()
737
- notNull ()
811
+ unsigned()
812
+ unique()
813
+ null()
814
+ notNull()
738
815
  primary()
739
- default (string)
740
- defaultTimestamp ()
741
- autoIncrement ()
816
+ default(string)
817
+ defaultTimestamp()
818
+ autoIncrement()
742
819
  ```
@@ -0,0 +1,4 @@
1
+ declare const _default: (cmd: {
2
+ [x: string]: any;
3
+ }) => void;
4
+ export default _default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const model_1 = __importDefault(require("../models/model"));
7
+ const pluralize_1 = __importDefault(require("pluralize"));
8
+ const lib_1 = require("../../lib");
9
+ exports.default = (cmd) => {
10
+ const { dir, cwd, type, fs, npm } = cmd;
11
+ if (dir) {
12
+ try {
13
+ fs.accessSync(cwd + `/${dir}`, fs.F_OK, {
14
+ recursive: true
15
+ });
16
+ }
17
+ catch (e) {
18
+ fs.mkdirSync(cwd + `/${dir}`, {
19
+ recursive: true
20
+ });
21
+ }
22
+ }
23
+ const snakeCaseToPascal = (data) => {
24
+ let str = data.split('_');
25
+ for (let i = 0; i < str.length; i++) {
26
+ str[i] = str[i].slice(0, 1).toUpperCase() + str[i].slice(1, str[i].length);
27
+ }
28
+ return str.join('');
29
+ };
30
+ new lib_1.DB().rawQuery('SHOW TABLES').then(tables => {
31
+ var _a;
32
+ for (let i = 0; i < tables.length; i++) {
33
+ const table = String((_a = Object.values(tables[i])) === null || _a === void 0 ? void 0 : _a.shift());
34
+ const model = snakeCaseToPascal(pluralize_1.default.singular(table));
35
+ const data = (0, model_1.default)(model, npm);
36
+ fs.writeFile(`${cwd}/${dir}/${model}${type !== null && type !== void 0 ? type : '.ts'}`, data, (err) => {
37
+ if (err)
38
+ throw err;
39
+ });
40
+ console.log(`Model : '${model}' created successfully`);
41
+ }
42
+ console.log('\nGenerate Models has completed');
43
+ })
44
+ .catch(err => console.log(err));
45
+ };
package/dist/cli/index.js CHANGED
@@ -3,30 +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;
6
7
  Object.defineProperty(exports, "__esModule", { value: true });
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const make_1 = __importDefault(require("./models/make"));
9
10
  const make_2 = __importDefault(require("./tables/make"));
10
11
  const make_3 = __importDefault(require("./migrate/make"));
12
+ const make_4 = __importDefault(require("./generate/make"));
13
+ const query_1 = __importDefault(require("./query"));
11
14
  const commands = {
15
+ 'query': query_1.default,
12
16
  'make:model': make_1.default,
13
17
  'make:table': make_2.default,
14
18
  'make:migration': make_2.default,
15
- 'migrate': make_3.default
19
+ 'migrate': make_3.default,
20
+ 'generate:models': make_4.default
16
21
  };
17
22
  try {
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';
23
+ const name = (_c = (_b = (_a = process.argv.slice(2)) === null || _a === void 0 ? void 0 : _a.find(data => {
24
+ return data === null || data === void 0 ? void 0 : data.includes('--name=');
25
+ })) === null || _b === void 0 ? void 0 : _b.replace('--name=', '')) !== null && _c !== void 0 ? _c : null;
26
+ const sql = (_d = process.argv.slice(3)[0]) !== null && _d !== void 0 ? _d : '';
27
+ const migrate = (_f = (_e = process.argv.slice(2)) === null || _e === void 0 ? void 0 : _e.includes('--m')) !== null && _f !== void 0 ? _f : false;
28
+ const dir = (_j = (_h = (_g = process.argv.slice(2)) === null || _g === void 0 ? void 0 : _g.find(data => {
29
+ return data === null || data === void 0 ? void 0 : data.includes('--dir=');
30
+ })) === null || _h === void 0 ? void 0 : _h.replace('--dir=', '/')) !== null && _j !== void 0 ? _j : null;
31
+ let type = (_m = (_l = (_k = process.argv.slice(2)) === null || _k === void 0 ? void 0 : _k.find(data => {
32
+ return data === null || data === void 0 ? void 0 : data.includes('--type=');
33
+ })) === null || _l === void 0 ? void 0 : _l.replace('--type=', '.')) !== null && _m !== void 0 ? _m : '.ts';
28
34
  type = ['.js', '.ts'].includes(type) ? type : '.ts';
29
- const file = process.argv.slice(3)?.shift() ?? '';
35
+ const file = (_o = process.argv.slice(3)[0]) !== null && _o !== void 0 ? _o : '';
30
36
  const cmd = {
31
37
  name,
32
38
  file,
@@ -35,10 +41,18 @@ try {
35
41
  type,
36
42
  cwd: process.cwd(),
37
43
  fs: fs_1.default,
44
+ sql,
38
45
  npm: 'tspace-mysql'
39
46
  };
40
47
  commands[process.argv[2]](cmd);
41
48
  }
42
49
  catch (err) {
43
- console.log(`readme https://www.npmjs.com/package/tspace-mysql`);
50
+ console.log(`
51
+ tspace-mysql make:model User --m --dir=app/Models
52
+ tspace-mysql make:migration users --dir=app/Models/Migrations
53
+ tspace-mysql migrate --dir=App/Models/Migrations --type=js
54
+ tspace-mysql query "SELECT * FROM users"
55
+ tspace-mysql generate:models --dir=app/Models
56
+ `);
57
+ console.log(`Read more https://www.npmjs.com/package/tspace-mysql`);
44
58
  }
@@ -2,22 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const child_process_1 = require("child_process");
4
4
  exports.default = (formCommand) => {
5
+ var _a, _b, _c;
5
6
  const { type, dir, cwd, fs } = formCommand;
6
7
  try {
7
8
  if (dir == null)
8
9
  throw new Error('Not found directory');
9
10
  const path = `${cwd}/${dir}`;
10
- const files = fs.readdirSync(path) ?? [];
11
- if (!files?.length)
11
+ const files = (_a = fs.readdirSync(path)) !== null && _a !== void 0 ? _a : [];
12
+ if (!(files === null || files === void 0 ? void 0 : files.length))
12
13
  console.log('this folder is empty');
13
14
  const cmd = type === '.js' ? 'node' : 'ts-node';
14
15
  for (const _file of files) {
15
16
  const run = (0, child_process_1.exec)(`${cmd} ${path}/${_file}`);
16
- run?.stdout?.on('data', (data) => {
17
+ (_b = run === null || run === void 0 ? void 0 : run.stdout) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
17
18
  if (data)
18
19
  console.log(data);
19
20
  });
20
- run?.stderr?.on('data', (err) => {
21
+ (_c = run === null || run === void 0 ? void 0 : run.stderr) === null || _c === void 0 ? void 0 : _c.on('data', (err) => {
21
22
  if (err)
22
23
  console.error(err);
23
24
  });
@@ -1,4 +1,4 @@
1
- declare const _default: (formCommand: {
1
+ declare const _default: (cmd: {
2
2
  [x: string]: any;
3
3
  }) => void;
4
4
  export default _default;
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const model_1 = __importDefault(require("./model"));
7
7
  const table_1 = __importDefault(require("../tables/table"));
8
8
  const pluralize_1 = __importDefault(require("pluralize"));
9
- exports.default = (formCommand) => {
10
- const { file, migrate, dir, type, cwd, fs, npm } = formCommand;
9
+ exports.default = (cmd) => {
10
+ const { file, migrate, dir, type, cwd, fs, npm } = cmd;
11
11
  if (dir) {
12
12
  try {
13
13
  fs.accessSync(cwd + `/${dir}`, fs.F_OK, {
@@ -14,10 +14,9 @@ class ${model} extends Model {
14
14
  * this.usePrimaryKey('id') // => runing a uuid (universally unique identifier) when insert new data
15
15
  * this.useTimestamp({ createdAt : 'created_at' , updatedAt : 'updated_at' }) // runing a timestamp when insert or update
16
16
  * this.useSoftDelete()
17
- * this.useDisableSoftDeleteInRelations()
18
- * this.useTable('Users')
19
- * this.useTableSingular()
20
- * this.useTablePlural()
17
+ * this.useTable('users')
18
+ * this.useTableSingular() // 'user'
19
+ * this.useTablePlural() // 'users'
21
20
  * this.usePattern('snake_case')
22
21
  * this.useUUID('uuid')
23
22
  * this.useRegistry()
@@ -0,0 +1,4 @@
1
+ declare const _default: (cmd: {
2
+ [x: string]: any;
3
+ }) => void;
4
+ export default _default;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lib_1 = require("../../lib");
4
+ exports.default = (cmd) => {
5
+ const { sql } = cmd;
6
+ new lib_1.DB().rawQuery(sql === null || sql === void 0 ? void 0 : sql.replace(/`/g, '')).then(result => console.log(result));
7
+ };
@@ -1,29 +1,4 @@
1
- export interface PoolCallback {
2
- query: (sql: string, callback: (err: any, result: any) => void) => void;
3
- release: () => void;
4
- }
5
- export interface ConnectionTransaction {
6
- query: (sql: string) => Promise<any>;
7
- startTransaction: () => Promise<any>;
8
- commit: () => Promise<any>;
9
- rollback: () => Promise<any>;
10
- }
11
- export interface Connection {
12
- query: (sql: string) => Promise<any>;
13
- connection: () => Promise<ConnectionTransaction>;
14
- }
15
- export interface Options {
16
- [key: string]: any;
17
- connectionLimit?: number;
18
- dateStrings?: boolean;
19
- waitForConnections?: boolean;
20
- charset?: string;
21
- host: string;
22
- port: number;
23
- database: string;
24
- user: string;
25
- password: string;
26
- }
1
+ import { Connection, Options } from '../tspace/Interface';
27
2
  export declare class PoolConnection {
28
3
  private OPTIONS;
29
4
  /**
@@ -31,12 +6,6 @@ export declare class PoolConnection {
31
6
  * @Init a options connection pool
32
7
  */
33
8
  constructor(options?: Options);
34
- /**
35
- *
36
- * Set a options connection pool
37
- * @return {this} this
38
- */
39
- options(options: Options): this;
40
9
  /**
41
10
  *
42
11
  * Get a connection to database
@@ -49,6 +18,13 @@ export declare class PoolConnection {
49
18
  private _loadOptions;
50
19
  private _messageError;
51
20
  }
21
+ /**
22
+ *
23
+ * Connection to database when service is started
24
+ * @return {Connection} Connection
25
+ * @property {Function} Connection.query
26
+ * @property {Function} Connection.connection
27
+ */
52
28
  declare const pool: Connection;
53
29
  export { pool as Pool };
54
30
  export default pool;