multi-db-orm 2.1.7 → 2.1.9
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/.github/workflows/npm-publish.yml +24 -24
- package/.vscode/launch.json +29 -29
- package/.vscode/settings.json +10 -10
- package/Dockerfile +17 -17
- package/README.md +229 -229
- package/backup.js +107 -107
- package/databases.js +14 -14
- package/engines/firestoredb.d.ts +39 -39
- package/engines/firestoredb.js +230 -230
- package/engines/index.d.ts +5 -5
- package/engines/metrics.d.ts +8 -8
- package/engines/metrics.js +77 -77
- package/engines/mongodb.d.ts +18 -18
- package/engines/mongodb.js +148 -148
- package/engines/multidb.d.ts +29 -29
- package/engines/multidb.js +67 -67
- package/engines/mysqldb.d.ts +44 -44
- package/engines/mysqldb.js +227 -227
- package/engines/oracledb.d.ts +24 -24
- package/engines/oracledb.js +250 -250
- package/engines/sqlitedb.d.ts +11 -11
- package/engines/sqlitedb.js +172 -172
- package/index.d.ts +7 -7
- package/index.js +11 -11
- package/migrate.sh +11 -11
- package/package.json +49 -49
- package/postinstall.js +8 -8
- package/restore.js +102 -102
- package/sync.d.ts +5 -5
- package/sync.js +48 -48
- package/test/models.js +23 -23
- package/test/test.js +279 -279
package/engines/mongodb.js
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
const { MultiDbORM } = require("./multidb");
|
|
2
|
-
|
|
3
|
-
class MongoDB extends MultiDbORM {
|
|
4
|
-
|
|
5
|
-
mongodbname
|
|
6
|
-
dbc
|
|
7
|
-
client
|
|
8
|
-
url
|
|
9
|
-
constructor(secureUrl, mongodbname) {
|
|
10
|
-
super()
|
|
11
|
-
|
|
12
|
-
this.url = secureUrl;
|
|
13
|
-
this.mongodbname = mongodbname
|
|
14
|
-
|
|
15
|
-
const MongoClient = require('mongodb').MongoClient;
|
|
16
|
-
this.client = new MongoClient(this.url, {
|
|
17
|
-
useUnifiedTopology: true,
|
|
18
|
-
useNewUrlParser: true
|
|
19
|
-
});
|
|
20
|
-
this._connect();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async _close() {
|
|
24
|
-
this.dbc.close();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async _connect() {
|
|
28
|
-
var dbc = await this.client.connect();
|
|
29
|
-
this.dbc = dbc;
|
|
30
|
-
this.db = dbc.db(this.mongodbname);
|
|
31
|
-
console.log("MongoDB Initialized");
|
|
32
|
-
this.dbType = 'mongodb'
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async run(query) {
|
|
36
|
-
if (this.loglevel > 3)
|
|
37
|
-
console.log('RUN : Not Supported in DB Type', this.dbType)
|
|
38
|
-
}
|
|
39
|
-
_inq2mongop(symbol) {
|
|
40
|
-
switch (symbol) {
|
|
41
|
-
case "=":
|
|
42
|
-
return "$eq";
|
|
43
|
-
case ">":
|
|
44
|
-
return "$gt";
|
|
45
|
-
case ">=":
|
|
46
|
-
return "$gte";
|
|
47
|
-
case "<":
|
|
48
|
-
return "$lt";
|
|
49
|
-
case "<=":
|
|
50
|
-
return "$lte";
|
|
51
|
-
case "!=":
|
|
52
|
-
return "$ne";
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async get(modelname, filter, options) {
|
|
56
|
-
this.metrics.get(modelname, filter, options);
|
|
57
|
-
if (options && options.apply && options.apply.ineq) {
|
|
58
|
-
filter[`${options.apply.field}`] = {};
|
|
59
|
-
filter[`${options.apply.field}`][`${this._inq2mongop(options.apply.ineq.op)}`] = options.apply.ineq.value
|
|
60
|
-
}
|
|
61
|
-
var crs = this.getdb().collection(modelname).find(filter);
|
|
62
|
-
if (options) {
|
|
63
|
-
if (options.apply) {
|
|
64
|
-
if (options.apply.sort) {
|
|
65
|
-
var order = 1;
|
|
66
|
-
if (options.apply.sort == 'desc') {
|
|
67
|
-
order = -1;
|
|
68
|
-
}
|
|
69
|
-
var sortOption = {};
|
|
70
|
-
sortOption[`${options.apply.field}`] = order;
|
|
71
|
-
crs = crs.sort(sortOption);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
} else if (options.sort) {
|
|
75
|
-
|
|
76
|
-
var sortOption = {};
|
|
77
|
-
options.sort.forEach(srt => {
|
|
78
|
-
var order = 1;
|
|
79
|
-
if (srt.order == 'desc') {
|
|
80
|
-
order = -1;
|
|
81
|
-
}
|
|
82
|
-
sortOption[`${srt.field}`] = order;
|
|
83
|
-
});
|
|
84
|
-
crs = crs.sort(sortOption);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (options.limit) {
|
|
88
|
-
crs.limit(options.limit)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (options.offset) {
|
|
92
|
-
crs.skip(options.offset)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
var snapshot = await crs.toArray()
|
|
97
|
-
return snapshot;
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async getOne(modelname, filter, options) {
|
|
102
|
-
this.metrics.getOne(modelname, filter, options);
|
|
103
|
-
var snapshot = await this.getdb().collection(modelname).findOne(filter)
|
|
104
|
-
return snapshot;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async create(modelname, sampleObject) {
|
|
108
|
-
this.sync.create(modelname, sampleObject)
|
|
109
|
-
this.metrics.create(modelname, sampleObject);
|
|
110
|
-
|
|
111
|
-
if (this.loglevel > 3)
|
|
112
|
-
console.log('CREATE : Not required in DB Type', this.dbType)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async insert(modelname, object) {
|
|
116
|
-
this.sync.insert(modelname, object)
|
|
117
|
-
this.metrics.insert(modelname, object)
|
|
118
|
-
|
|
119
|
-
const collref = this.getdb().collection(modelname)
|
|
120
|
-
try {
|
|
121
|
-
return await collref.insertOne(object);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
|
|
124
|
-
throw e;
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async update(modelname, filter, object) {
|
|
131
|
-
this.sync.update(modelname, filter, object)
|
|
132
|
-
this.metrics.update(modelname, filter, object)
|
|
133
|
-
var resp = await this.getdb().collection(modelname).updateMany(filter, { $set: object })
|
|
134
|
-
return resp;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async delete(modelname, filter) {
|
|
138
|
-
this.sync.delete(modelname, filter)
|
|
139
|
-
this.metrics.delete(modelname, filter)
|
|
140
|
-
var resp = await this.getdb().collection(modelname).deleteMany(filter)
|
|
141
|
-
return resp;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
module.exports = {
|
|
148
|
-
MongoDB
|
|
1
|
+
const { MultiDbORM } = require("./multidb");
|
|
2
|
+
|
|
3
|
+
class MongoDB extends MultiDbORM {
|
|
4
|
+
|
|
5
|
+
mongodbname
|
|
6
|
+
dbc
|
|
7
|
+
client
|
|
8
|
+
url
|
|
9
|
+
constructor(secureUrl, mongodbname) {
|
|
10
|
+
super()
|
|
11
|
+
|
|
12
|
+
this.url = secureUrl;
|
|
13
|
+
this.mongodbname = mongodbname
|
|
14
|
+
|
|
15
|
+
const MongoClient = require('mongodb').MongoClient;
|
|
16
|
+
this.client = new MongoClient(this.url, {
|
|
17
|
+
useUnifiedTopology: true,
|
|
18
|
+
useNewUrlParser: true
|
|
19
|
+
});
|
|
20
|
+
this._connect();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async _close() {
|
|
24
|
+
this.dbc.close();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async _connect() {
|
|
28
|
+
var dbc = await this.client.connect();
|
|
29
|
+
this.dbc = dbc;
|
|
30
|
+
this.db = dbc.db(this.mongodbname);
|
|
31
|
+
console.log("MongoDB Initialized");
|
|
32
|
+
this.dbType = 'mongodb'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async run(query) {
|
|
36
|
+
if (this.loglevel > 3)
|
|
37
|
+
console.log('RUN : Not Supported in DB Type', this.dbType)
|
|
38
|
+
}
|
|
39
|
+
_inq2mongop(symbol) {
|
|
40
|
+
switch (symbol) {
|
|
41
|
+
case "=":
|
|
42
|
+
return "$eq";
|
|
43
|
+
case ">":
|
|
44
|
+
return "$gt";
|
|
45
|
+
case ">=":
|
|
46
|
+
return "$gte";
|
|
47
|
+
case "<":
|
|
48
|
+
return "$lt";
|
|
49
|
+
case "<=":
|
|
50
|
+
return "$lte";
|
|
51
|
+
case "!=":
|
|
52
|
+
return "$ne";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async get(modelname, filter, options) {
|
|
56
|
+
this.metrics.get(modelname, filter, options);
|
|
57
|
+
if (options && options.apply && options.apply.ineq) {
|
|
58
|
+
filter[`${options.apply.field}`] = {};
|
|
59
|
+
filter[`${options.apply.field}`][`${this._inq2mongop(options.apply.ineq.op)}`] = options.apply.ineq.value
|
|
60
|
+
}
|
|
61
|
+
var crs = this.getdb().collection(modelname).find(filter);
|
|
62
|
+
if (options) {
|
|
63
|
+
if (options.apply) {
|
|
64
|
+
if (options.apply.sort) {
|
|
65
|
+
var order = 1;
|
|
66
|
+
if (options.apply.sort == 'desc') {
|
|
67
|
+
order = -1;
|
|
68
|
+
}
|
|
69
|
+
var sortOption = {};
|
|
70
|
+
sortOption[`${options.apply.field}`] = order;
|
|
71
|
+
crs = crs.sort(sortOption);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} else if (options.sort) {
|
|
75
|
+
|
|
76
|
+
var sortOption = {};
|
|
77
|
+
options.sort.forEach(srt => {
|
|
78
|
+
var order = 1;
|
|
79
|
+
if (srt.order == 'desc') {
|
|
80
|
+
order = -1;
|
|
81
|
+
}
|
|
82
|
+
sortOption[`${srt.field}`] = order;
|
|
83
|
+
});
|
|
84
|
+
crs = crs.sort(sortOption);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (options.limit) {
|
|
88
|
+
crs.limit(options.limit)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (options.offset) {
|
|
92
|
+
crs.skip(options.offset)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var snapshot = await crs.toArray()
|
|
97
|
+
return snapshot;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async getOne(modelname, filter, options) {
|
|
102
|
+
this.metrics.getOne(modelname, filter, options);
|
|
103
|
+
var snapshot = await this.getdb().collection(modelname).findOne(filter)
|
|
104
|
+
return snapshot;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async create(modelname, sampleObject) {
|
|
108
|
+
this.sync.create(modelname, sampleObject)
|
|
109
|
+
this.metrics.create(modelname, sampleObject);
|
|
110
|
+
|
|
111
|
+
if (this.loglevel > 3)
|
|
112
|
+
console.log('CREATE : Not required in DB Type', this.dbType)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async insert(modelname, object) {
|
|
116
|
+
this.sync.insert(modelname, object)
|
|
117
|
+
this.metrics.insert(modelname, object)
|
|
118
|
+
|
|
119
|
+
const collref = this.getdb().collection(modelname)
|
|
120
|
+
try {
|
|
121
|
+
return await collref.insertOne(object);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
|
|
124
|
+
throw e;
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async update(modelname, filter, object) {
|
|
131
|
+
this.sync.update(modelname, filter, object)
|
|
132
|
+
this.metrics.update(modelname, filter, object)
|
|
133
|
+
var resp = await this.getdb().collection(modelname).updateMany(filter, { $set: object })
|
|
134
|
+
return resp;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async delete(modelname, filter) {
|
|
138
|
+
this.sync.delete(modelname, filter)
|
|
139
|
+
this.metrics.delete(modelname, filter)
|
|
140
|
+
var resp = await this.getdb().collection(modelname).deleteMany(filter)
|
|
141
|
+
return resp;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
module.exports = {
|
|
148
|
+
MongoDB
|
|
149
149
|
}
|
package/engines/multidb.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export class MultiDbORM {
|
|
2
|
-
db: any;
|
|
3
|
-
dbType: string;
|
|
4
|
-
reqMade: number;
|
|
5
|
-
lastQLatency: any;
|
|
6
|
-
loglevel: number;
|
|
7
|
-
sync: import('../sync').Sync;
|
|
8
|
-
metrics: import('./metrics').Metrics;
|
|
9
|
-
|
|
10
|
-
constructor(db: any);
|
|
11
|
-
|
|
12
|
-
async connect(): Promise<void>;
|
|
13
|
-
|
|
14
|
-
setdb(db: any): void;
|
|
15
|
-
|
|
16
|
-
getdb(): any;
|
|
17
|
-
|
|
18
|
-
async get(modelname: string, filter: Record<string, any>): Promise<
|
|
19
|
-
|
|
20
|
-
async getOne(modelname: string, filter: Record<string, any>): Promise<
|
|
21
|
-
|
|
22
|
-
async create(modelname: string, object: Record<string, any>): Promise<
|
|
23
|
-
|
|
24
|
-
async insert(modelname: string, object: Record<string, any>): Promise<
|
|
25
|
-
|
|
26
|
-
async update(modelname: string, filter: Record<string, any>, object: Record<string, any>): Promise<
|
|
27
|
-
|
|
28
|
-
async delete(modelname: string, filter: Record<string, any>): Promise<
|
|
29
|
-
}
|
|
1
|
+
export class MultiDbORM {
|
|
2
|
+
db: any;
|
|
3
|
+
dbType: string;
|
|
4
|
+
reqMade: number;
|
|
5
|
+
lastQLatency: any;
|
|
6
|
+
loglevel: number;
|
|
7
|
+
sync: import('../sync').Sync;
|
|
8
|
+
metrics: import('./metrics').Metrics;
|
|
9
|
+
|
|
10
|
+
constructor(db: any);
|
|
11
|
+
|
|
12
|
+
async connect(): Promise<void>;
|
|
13
|
+
|
|
14
|
+
setdb(db: any): void;
|
|
15
|
+
|
|
16
|
+
getdb(): any;
|
|
17
|
+
|
|
18
|
+
async get(modelname: string, filter: Record<string, any>): Promise<any>;
|
|
19
|
+
|
|
20
|
+
async getOne(modelname: string, filter: Record<string, any>): Promise<any>;
|
|
21
|
+
|
|
22
|
+
async create(modelname: string, object: Record<string, any>): Promise<any>;
|
|
23
|
+
|
|
24
|
+
async insert(modelname: string, object: Record<string, any>): Promise<any>;
|
|
25
|
+
|
|
26
|
+
async update(modelname: string, filter: Record<string, any>, object: Record<string, any>): Promise<any>;
|
|
27
|
+
|
|
28
|
+
async delete(modelname: string, filter: Record<string, any>): Promise<any>;
|
|
29
|
+
}
|
package/engines/multidb.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
const { Sync } = require('../sync')
|
|
2
|
-
const { Metrics } = require('./metrics')
|
|
3
|
-
class MultiDbORM {
|
|
4
|
-
|
|
5
|
-
db
|
|
6
|
-
dbType
|
|
7
|
-
reqMade
|
|
8
|
-
lastQLatency
|
|
9
|
-
loglevel = 0
|
|
10
|
-
sync
|
|
11
|
-
metrics
|
|
12
|
-
|
|
13
|
-
constructor(db) {
|
|
14
|
-
this.db = db
|
|
15
|
-
this.sync = new Sync()
|
|
16
|
-
this.metrics = new Metrics(this.loglevel)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async connect() {
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
setdb(db) {
|
|
24
|
-
this.reqMade = 0
|
|
25
|
-
this.db = db;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getdb() {
|
|
29
|
-
this.reqMade++
|
|
30
|
-
return this.db;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async get(modelname, filter) {
|
|
34
|
-
if (this.loglevel > 4)
|
|
35
|
-
console.log("Not implemented")
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async getOne(modelname, filter) {
|
|
39
|
-
if (this.loglevel > 4)
|
|
40
|
-
console.log("Not implemented")
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async create(modelname, object) {
|
|
44
|
-
if (this.loglevel > 4)
|
|
45
|
-
console.log("Not implemented")
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async insert(modelname, object) {
|
|
49
|
-
if (this.loglevel > 4)
|
|
50
|
-
console.log("Not implemented")
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async update(modelname, filter, object) {
|
|
54
|
-
if (this.loglevel > 4)
|
|
55
|
-
console.log("Not implemented")
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async delete(modelname, filter) {
|
|
59
|
-
if (this.loglevel > 4)
|
|
60
|
-
console.log("Not implemented")
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
module.exports = {
|
|
67
|
-
MultiDbORM: MultiDbORM
|
|
1
|
+
const { Sync } = require('../sync')
|
|
2
|
+
const { Metrics } = require('./metrics')
|
|
3
|
+
class MultiDbORM {
|
|
4
|
+
|
|
5
|
+
db
|
|
6
|
+
dbType
|
|
7
|
+
reqMade
|
|
8
|
+
lastQLatency
|
|
9
|
+
loglevel = 0
|
|
10
|
+
sync
|
|
11
|
+
metrics
|
|
12
|
+
|
|
13
|
+
constructor(db) {
|
|
14
|
+
this.db = db
|
|
15
|
+
this.sync = new Sync()
|
|
16
|
+
this.metrics = new Metrics(this.loglevel)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async connect() {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setdb(db) {
|
|
24
|
+
this.reqMade = 0
|
|
25
|
+
this.db = db;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getdb() {
|
|
29
|
+
this.reqMade++
|
|
30
|
+
return this.db;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async get(modelname, filter) {
|
|
34
|
+
if (this.loglevel > 4)
|
|
35
|
+
console.log("Not implemented")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async getOne(modelname, filter) {
|
|
39
|
+
if (this.loglevel > 4)
|
|
40
|
+
console.log("Not implemented")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async create(modelname, object) {
|
|
44
|
+
if (this.loglevel > 4)
|
|
45
|
+
console.log("Not implemented")
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async insert(modelname, object) {
|
|
49
|
+
if (this.loglevel > 4)
|
|
50
|
+
console.log("Not implemented")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async update(modelname, filter, object) {
|
|
54
|
+
if (this.loglevel > 4)
|
|
55
|
+
console.log("Not implemented")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async delete(modelname, filter) {
|
|
59
|
+
if (this.loglevel > 4)
|
|
60
|
+
console.log("Not implemented")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
module.exports = {
|
|
67
|
+
MultiDbORM: MultiDbORM
|
|
68
68
|
}
|
package/engines/mysqldb.d.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { MultiDbORM } from './multidb';
|
|
2
|
-
|
|
3
|
-
declare module 'mysql' {
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
|
|
6
|
-
export interface ConnectionConfig {
|
|
7
|
-
host: string;
|
|
8
|
-
port: number;
|
|
9
|
-
user: string;
|
|
10
|
-
password: string;
|
|
11
|
-
database?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class Connection extends EventEmitter {
|
|
15
|
-
constructor(config: ConnectionConfig);
|
|
16
|
-
connect(): void;
|
|
17
|
-
end(): void;
|
|
18
|
-
query(query: string, callback: (error: Error | null, results: any, fields: any) => void): void;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type MySQLDBConfig = {
|
|
23
|
-
host: string;
|
|
24
|
-
port: string;
|
|
25
|
-
username: string;
|
|
26
|
-
password: string;
|
|
27
|
-
database: string;
|
|
28
|
-
connectionLimit?: Number;
|
|
29
|
-
connectTimeout?: Number;
|
|
30
|
-
acquireTimeout?: Number;
|
|
31
|
-
timeout?: Number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class MySQLDB extends MultiDbORM {
|
|
35
|
-
db: typeof import('mysql')
|
|
36
|
-
mysql: typeof import('mysql');
|
|
37
|
-
connection: import('mysql').Connection;
|
|
38
|
-
|
|
39
|
-
constructor(credentials: MySQLDBConfig);
|
|
40
|
-
|
|
41
|
-
run(query: string): Promise<any[]>;
|
|
42
|
-
|
|
43
|
-
closePool(): void;
|
|
44
|
-
}
|
|
1
|
+
import { MultiDbORM } from './multidb';
|
|
2
|
+
|
|
3
|
+
declare module 'mysql' {
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
|
|
6
|
+
export interface ConnectionConfig {
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
user: string;
|
|
10
|
+
password: string;
|
|
11
|
+
database?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Connection extends EventEmitter {
|
|
15
|
+
constructor(config: ConnectionConfig);
|
|
16
|
+
connect(): void;
|
|
17
|
+
end(): void;
|
|
18
|
+
query(query: string, callback: (error: Error | null, results: any, fields: any) => void): void;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type MySQLDBConfig = {
|
|
23
|
+
host: string;
|
|
24
|
+
port: string;
|
|
25
|
+
username: string;
|
|
26
|
+
password: string;
|
|
27
|
+
database: string;
|
|
28
|
+
connectionLimit?: Number;
|
|
29
|
+
connectTimeout?: Number;
|
|
30
|
+
acquireTimeout?: Number;
|
|
31
|
+
timeout?: Number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class MySQLDB extends MultiDbORM {
|
|
35
|
+
db: typeof import('mysql')
|
|
36
|
+
mysql: typeof import('mysql');
|
|
37
|
+
connection: import('mysql').Connection;
|
|
38
|
+
|
|
39
|
+
constructor(credentials: MySQLDBConfig);
|
|
40
|
+
|
|
41
|
+
run(query: string): Promise<any[]>;
|
|
42
|
+
|
|
43
|
+
closePool(): void;
|
|
44
|
+
}
|