multi-db-orm 2.1.26 → 3.0.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.
- package/README.md +67 -37
- package/databases.js +11 -9
- package/engines/hanadb.d.ts +24 -0
- package/engines/hanadb.js +249 -0
- package/engines/index.d.ts +2 -1
- package/engines/mysqldb.js +1 -1
- package/engines/sqlitedb.js +146 -154
- package/index.js +18 -9
- package/package.json +3 -2
- package/test/test.js +395 -241
package/test/test.js
CHANGED
|
@@ -1,280 +1,434 @@
|
|
|
1
1
|
const { Game } = require("./models");
|
|
2
|
-
const {
|
|
3
|
-
|
|
2
|
+
const {
|
|
3
|
+
MultiDBSafe,
|
|
4
|
+
FireStoreDB,
|
|
5
|
+
MongoDB,
|
|
6
|
+
SQLiteDB,
|
|
7
|
+
Sync,
|
|
8
|
+
OracleDB,
|
|
9
|
+
} = require("../index");
|
|
10
|
+
const path = require("path");
|
|
4
11
|
const { MySQLDB } = require("../engines/mysqldb");
|
|
12
|
+
const { HanaDB } = require("../engines/hanadb");
|
|
5
13
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var testCount = 0
|
|
14
|
+
var testCount = 0;
|
|
9
15
|
function checkTestsCompleted() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
if (--testCount <= 0) {
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
async function testSqlite() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
var sqlitedb = new SQLiteDB();
|
|
23
|
+
console.log(sqlitedb.metrics.getStatus());
|
|
24
|
+
var gm = new Game("IndVSPak", Date.now(), "Dhoni", 67.33, "paid");
|
|
25
|
+
sqlitedb.loglevel = 1;
|
|
26
|
+
var res = await sqlitedb.create("games", gm);
|
|
27
|
+
res = await sqlitedb.insert("games", gm);
|
|
28
|
+
res = await sqlitedb.insert("games", gm);
|
|
29
|
+
gm.amount = 1;
|
|
30
|
+
res = await sqlitedb.insert("games", gm);
|
|
31
|
+
res = await sqlitedb.get("games", { amount: 1 });
|
|
32
|
+
res = await sqlitedb.getOne("games", { amount: 1 });
|
|
33
|
+
res = await sqlitedb.update("games", { amount: 1 }, { userid: "xxxx" });
|
|
34
|
+
res = await sqlitedb.getOne("games", { userid: "xxxx" });
|
|
35
|
+
|
|
36
|
+
res = await sqlitedb.insert(
|
|
37
|
+
"games",
|
|
38
|
+
new Game("IndVSPak1", Date.now(), "Dhoni", 100, "free")
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
res = await sqlitedb.insert(
|
|
42
|
+
"games",
|
|
43
|
+
new Game("IndVSPak2", Date.now(), "Dhoni", 200, "free")
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
res = await sqlitedb.insert(
|
|
47
|
+
"games",
|
|
48
|
+
new Game("IndVSPak3", Date.now(), "Dhoni", 300, "paid")
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
res = await sqlitedb.insert(
|
|
52
|
+
"games",
|
|
53
|
+
new Game("IndVSPak4", Date.now(), "Dhoni", 400, "paid")
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
res = await sqlitedb.get("games", undefined, {
|
|
57
|
+
sort: [
|
|
58
|
+
{ field: "timeStamp", order: "asc" },
|
|
59
|
+
{ field: "amount", order: "asc" },
|
|
60
|
+
],
|
|
61
|
+
limit: 5,
|
|
62
|
+
offset: 1,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
res = await sqlitedb.get(
|
|
66
|
+
"games",
|
|
67
|
+
{ type: "paid" },
|
|
68
|
+
{
|
|
69
|
+
sort: [
|
|
70
|
+
{ field: "amount", order: "desc" },
|
|
71
|
+
{ field: "timeStamp", order: "desc" },
|
|
72
|
+
],
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
res = await sqlitedb.get(
|
|
77
|
+
"games",
|
|
78
|
+
{ amount: 400 },
|
|
79
|
+
{
|
|
80
|
+
apply: {
|
|
81
|
+
field: "timeStamp",
|
|
82
|
+
sort: "desc",
|
|
83
|
+
ineq: {
|
|
84
|
+
op: ">=",
|
|
85
|
+
value: 1,
|
|
50
86
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
87
|
+
},
|
|
88
|
+
sort: [
|
|
89
|
+
{ field: "amount", order: "asc" },
|
|
90
|
+
{ field: "timeStamp", order: "desc" },
|
|
91
|
+
],
|
|
92
|
+
limit: 2,
|
|
93
|
+
offset: 1,
|
|
94
|
+
}
|
|
95
|
+
);
|
|
54
96
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
97
|
+
console.log("SQLite DB Tests Successfull");
|
|
98
|
+
console.log(sqlitedb.metrics.getStatus());
|
|
99
|
+
checkTestsCompleted();
|
|
58
100
|
}
|
|
59
101
|
|
|
60
|
-
|
|
61
102
|
async function testFireStore() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
103
|
+
try {
|
|
104
|
+
require("../creds.json");
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.log("testFireStore", "creds.json not found");
|
|
107
|
+
checkTestsCompleted();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
var firebasedb = new FireStoreDB(require("../creds.json"));
|
|
111
|
+
console.log(firebasedb.metrics.getStatus());
|
|
112
|
+
|
|
113
|
+
var gm = new Game("IndVSPak", Date.now(), "Dhoni", 67.33, "free");
|
|
114
|
+
firebasedb.loglevel = 1;
|
|
115
|
+
var res = await firebasedb.create("games", gm);
|
|
116
|
+
res = await firebasedb.insert("games", gm, Date.now());
|
|
117
|
+
res = await firebasedb.insert("games", gm, Date.now());
|
|
118
|
+
gm.amount = 1;
|
|
119
|
+
res = await firebasedb.insert("games", gm);
|
|
120
|
+
res = await firebasedb.get("games", { amount: 67.33 });
|
|
121
|
+
res = await firebasedb.getOne("games", { amount: 1 });
|
|
122
|
+
res = await firebasedb.update(
|
|
123
|
+
"games",
|
|
124
|
+
{ userid: "Dhoni" },
|
|
125
|
+
{ userid: "ABC123" }
|
|
126
|
+
);
|
|
127
|
+
res = await firebasedb.update("games", { id: "IndVSPak" }, { amount: 1000 });
|
|
128
|
+
await firebasedb.delete("games", { type: "free" });
|
|
129
|
+
|
|
130
|
+
res = await firebasedb.insert(
|
|
131
|
+
"games",
|
|
132
|
+
new Game("IndVSPak1", Date.now(), "Dhoni", 100, "free")
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
res = await firebasedb.insert(
|
|
136
|
+
"games",
|
|
137
|
+
new Game("IndVSPak2", Date.now(), "Dhoni", 200, "free")
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
res = await firebasedb.insert(
|
|
141
|
+
"games",
|
|
142
|
+
new Game("IndVSPak3", Date.now(), "Dhoni", 300, "paid")
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
res = await firebasedb.insert(
|
|
146
|
+
"games",
|
|
147
|
+
new Game("IndVSPak4", Date.now(), "Dhoni", 400, "paid")
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
res = await firebasedb.get("games", undefined, {
|
|
151
|
+
sort: [{ field: "amount", order: "desc" }],
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
res = await firebasedb.get("games", undefined, {
|
|
155
|
+
sort: [{ field: "amount", order: "desc" }],
|
|
156
|
+
limit: 2,
|
|
157
|
+
offset: 1,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// res = await firebasedb.get('games', {type:'paid'}, { sort: [{ field: 'amount', order: 'asc' }, { field: 'timeStamp', order: 'desc' }] })
|
|
161
|
+
|
|
162
|
+
res = await firebasedb.get(
|
|
163
|
+
"games",
|
|
164
|
+
{ amount: 100 },
|
|
165
|
+
{
|
|
166
|
+
apply: {
|
|
167
|
+
field: "timeStamp",
|
|
168
|
+
sort: "desc",
|
|
169
|
+
ineq: {
|
|
170
|
+
op: ">=",
|
|
171
|
+
value: 1,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
sort: [
|
|
175
|
+
{ field: "amount", order: "asc" },
|
|
176
|
+
{ field: "timeStamp", order: "desc" },
|
|
177
|
+
],
|
|
178
|
+
limit: 2,
|
|
179
|
+
offset: 1,
|
|
69
180
|
}
|
|
70
|
-
|
|
71
|
-
console.log(firebasedb.metrics.getStatus())
|
|
72
|
-
|
|
73
|
-
var gm = new Game('IndVSPak', Date.now(), 'Dhoni', 67.33, 'free')
|
|
74
|
-
firebasedb.loglevel = 1
|
|
75
|
-
var res = await firebasedb.create('games', gm);
|
|
76
|
-
res = await firebasedb.insert('games', gm, Date.now());
|
|
77
|
-
res = await firebasedb.insert('games', gm, Date.now());
|
|
78
|
-
gm.amount = 1
|
|
79
|
-
res = await firebasedb.insert('games', gm);
|
|
80
|
-
res = await firebasedb.get('games', { amount: 67.33 });
|
|
81
|
-
res = await firebasedb.getOne('games', { amount: 1 });
|
|
82
|
-
res = await firebasedb.update('games', { userid: 'Dhoni' }, { userid: 'ABC123' });
|
|
83
|
-
res = await firebasedb.update('games', { id: 'IndVSPak' }, { amount: 1000 });
|
|
84
|
-
await firebasedb.delete('games', { type: 'free' })
|
|
85
|
-
|
|
86
|
-
res = await firebasedb.insert('games', new Game('IndVSPak1', Date.now(), 'Dhoni', 100, 'free'));
|
|
87
|
-
|
|
88
|
-
res = await firebasedb.insert('games', new Game('IndVSPak2', Date.now(), 'Dhoni', 200, 'free'));
|
|
89
|
-
|
|
90
|
-
res = await firebasedb.insert('games', new Game('IndVSPak3', Date.now(), 'Dhoni', 300, 'paid'));
|
|
181
|
+
);
|
|
91
182
|
|
|
92
|
-
|
|
183
|
+
console.log("Firestore DB Tests Successfull");
|
|
184
|
+
console.log(firebasedb.metrics.getStatus());
|
|
93
185
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
res = await firebasedb.get('games', undefined, { sort: [{ field: 'amount', order: 'desc' }], limit: 2, offset: 1 })
|
|
97
|
-
|
|
98
|
-
// res = await firebasedb.get('games', {type:'paid'}, { sort: [{ field: 'amount', order: 'asc' }, { field: 'timeStamp', order: 'desc' }] })
|
|
186
|
+
checkTestsCompleted();
|
|
187
|
+
}
|
|
99
188
|
|
|
100
|
-
|
|
189
|
+
async function testMongo() {
|
|
190
|
+
try {
|
|
191
|
+
require("../creds.json");
|
|
192
|
+
} catch (e) {
|
|
193
|
+
console.log("testMongo", "creds.json not found");
|
|
194
|
+
checkTestsCompleted();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
var crd = require("../creds.json");
|
|
198
|
+
var mongodb = new MongoDB(crd.mongourl, crd.mongodbname);
|
|
199
|
+
console.log(mongodb.metrics.getStatus());
|
|
200
|
+
|
|
201
|
+
if (mongodb.db == undefined) {
|
|
202
|
+
await mongodb._connect();
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
var gm = new Game("IndVSPak", Date.now(), "Dhoni", 67.33, "free");
|
|
206
|
+
mongodb.loglevel = 1;
|
|
207
|
+
var res = await mongodb.create("games", gm);
|
|
208
|
+
res = await mongodb.insert("games", gm);
|
|
209
|
+
res = await mongodb.insert(
|
|
210
|
+
"games",
|
|
211
|
+
new Game("IndVSPak", Date.now(), "Dhoni", 67.33, "free")
|
|
212
|
+
);
|
|
213
|
+
res = await mongodb.get("games", { amount: 67.33 });
|
|
214
|
+
res = await mongodb.getOne("games", { amount: 1 });
|
|
215
|
+
res = await mongodb.update(
|
|
216
|
+
"games",
|
|
217
|
+
{ userid: "Dhoni" },
|
|
218
|
+
{ userid: "ABC123" }
|
|
219
|
+
);
|
|
220
|
+
res = await mongodb.update("games", { id: "IndVSPak" }, { amount: 1000 });
|
|
221
|
+
|
|
222
|
+
res = await mongodb.insert(
|
|
223
|
+
"games",
|
|
224
|
+
new Game("IndVSPak1", Date.now(), "Dhoni", 100, "free")
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
res = await mongodb.insert(
|
|
228
|
+
"games",
|
|
229
|
+
new Game("IndVSPak2", Date.now(), "Dhoni", 200, "free")
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
res = await mongodb.insert(
|
|
233
|
+
"games",
|
|
234
|
+
new Game("IndVSPak3", Date.now(), "Dhoni", 300, "paid")
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
res = await mongodb.insert(
|
|
238
|
+
"games",
|
|
239
|
+
new Game("IndVSPak4", Date.now(), "Dhoni", 400, "paid")
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
res = await mongodb.get("games", undefined, {
|
|
243
|
+
sort: [{ field: "amount", order: "desc" }],
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
res = await mongodb.get("games", undefined, {
|
|
247
|
+
sort: [
|
|
248
|
+
{ field: "timeStamp", order: "asc" },
|
|
249
|
+
{ field: "amount", order: "asc" },
|
|
250
|
+
],
|
|
251
|
+
limit: 5,
|
|
252
|
+
offset: 1,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
res = await mongodb.get(
|
|
256
|
+
"games",
|
|
257
|
+
{ type: "paid" },
|
|
258
|
+
{
|
|
259
|
+
sort: [
|
|
260
|
+
{ field: "amount", order: "asc" },
|
|
261
|
+
{ field: "timeStamp", order: "desc" },
|
|
262
|
+
],
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
res = await mongodb.get(
|
|
267
|
+
"games",
|
|
268
|
+
{ amount: 400 },
|
|
269
|
+
{
|
|
101
270
|
apply: {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
271
|
+
field: "timeStamp",
|
|
272
|
+
sort: "desc",
|
|
273
|
+
ineq: {
|
|
274
|
+
op: ">=",
|
|
275
|
+
value: 1,
|
|
276
|
+
},
|
|
108
277
|
},
|
|
109
|
-
sort: [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
278
|
+
sort: [
|
|
279
|
+
{ field: "amount", order: "asc" },
|
|
280
|
+
{ field: "timeStamp", order: "desc" },
|
|
281
|
+
],
|
|
282
|
+
limit: 2,
|
|
283
|
+
offset: 1,
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
await mongodb.delete("games", { type: "free" });
|
|
287
|
+
console.log("Mongo DB Tests Successfull");
|
|
288
|
+
console.log(mongodb.metrics.getStatus());
|
|
289
|
+
} finally {
|
|
290
|
+
mongodb._close();
|
|
116
291
|
checkTestsCompleted();
|
|
117
|
-
|
|
292
|
+
}
|
|
118
293
|
}
|
|
119
294
|
|
|
120
|
-
|
|
121
|
-
async function testMongo() {
|
|
122
|
-
try {
|
|
123
|
-
require('../creds.json')
|
|
124
|
-
|
|
125
|
-
} catch (e) {
|
|
126
|
-
console.log('testMongo', 'creds.json not found');
|
|
127
|
-
checkTestsCompleted();
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
var crd = require('../creds.json')
|
|
131
|
-
var mongodb = new MongoDB(crd.mongourl, crd.mongodbname);
|
|
132
|
-
console.log(mongodb.metrics.getStatus())
|
|
133
|
-
|
|
134
|
-
if (mongodb.db == undefined) {
|
|
135
|
-
await mongodb._connect();
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
var gm = new Game('IndVSPak', Date.now(), 'Dhoni', 67.33, 'free')
|
|
139
|
-
mongodb.loglevel = 1
|
|
140
|
-
var res = await mongodb.create('games', gm);
|
|
141
|
-
res = await mongodb.insert('games', gm);
|
|
142
|
-
res = await mongodb.insert('games',
|
|
143
|
-
new Game('IndVSPak', Date.now(), 'Dhoni', 67.33, 'free'));
|
|
144
|
-
res = await mongodb.get('games', { amount: 67.33 });
|
|
145
|
-
res = await mongodb.getOne('games', { amount: 1 });
|
|
146
|
-
res = await mongodb.update('games', { userid: 'Dhoni' }, { userid: 'ABC123' });
|
|
147
|
-
res = await mongodb.update('games', { id: 'IndVSPak' }, { amount: 1000 });
|
|
148
|
-
|
|
149
|
-
res = await mongodb.insert('games', new Game('IndVSPak1', Date.now(), 'Dhoni', 100, 'free'));
|
|
150
|
-
|
|
151
|
-
res = await mongodb.insert('games', new Game('IndVSPak2', Date.now(), 'Dhoni', 200, 'free'));
|
|
152
|
-
|
|
153
|
-
res = await mongodb.insert('games', new Game('IndVSPak3', Date.now(), 'Dhoni', 300, 'paid'));
|
|
154
|
-
|
|
155
|
-
res = await mongodb.insert('games', new Game('IndVSPak4', Date.now(), 'Dhoni', 400, 'paid'));
|
|
156
|
-
|
|
157
|
-
res = await mongodb.get('games', undefined, { sort: [{ field: 'amount', order: 'desc' }] })
|
|
158
|
-
|
|
159
|
-
res = await mongodb.get('games', undefined, { sort: [{ field: 'timeStamp', order: 'asc' }, { field: 'amount', order: 'asc' }], limit: 5, offset: 1 })
|
|
160
|
-
|
|
161
|
-
res = await mongodb.get('games', { type: 'paid' }, { sort: [{ field: 'amount', order: 'asc' }, { field: 'timeStamp', order: 'desc' }] })
|
|
162
|
-
|
|
163
|
-
res = await mongodb.get('games', { amount: 400 }, {
|
|
164
|
-
apply: {
|
|
165
|
-
field: 'timeStamp',
|
|
166
|
-
sort: 'desc',
|
|
167
|
-
ineq: {
|
|
168
|
-
op: '>=',
|
|
169
|
-
value: 1
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
sort: [{ field: 'amount', order: 'asc' }, { field: 'timeStamp', order: 'desc' }],
|
|
173
|
-
limit: 2, offset: 1
|
|
174
|
-
})
|
|
175
|
-
await mongodb.delete('games', { type: 'free' })
|
|
176
|
-
console.log('Mongo DB Tests Successfull')
|
|
177
|
-
console.log(mongodb.metrics.getStatus())
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} finally {
|
|
181
|
-
mongodb._close();
|
|
182
|
-
checkTestsCompleted();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
295
|
async function testOracleDb() {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
296
|
+
let creds = require("../creds/oracle/creds.json");
|
|
297
|
+
creds.wallet_dir = path.join(__dirname, "../creds/oracle");
|
|
298
|
+
var oracledb = new OracleDB(creds);
|
|
299
|
+
console.log(oracledb.metrics.getStatus());
|
|
300
|
+
var gm = new Game("IndVSPak", Date.now(), "Dhoni", 67.33, "paid");
|
|
301
|
+
gm.completed = true;
|
|
302
|
+
gm.runs = ["a", "b"];
|
|
303
|
+
gm.extras = {
|
|
304
|
+
location: "India",
|
|
305
|
+
raining: false,
|
|
306
|
+
match: 1,
|
|
307
|
+
};
|
|
308
|
+
oracledb.loglevel = 1;
|
|
309
|
+
await oracledb.connect();
|
|
310
|
+
test(oracledb);
|
|
204
311
|
}
|
|
205
312
|
|
|
206
|
-
|
|
207
|
-
|
|
208
313
|
async function testMysqlDb() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
314
|
+
let creds = require("../creds/mysql.json");
|
|
315
|
+
var mysqldb = new MySQLDB(creds);
|
|
316
|
+
console.log(mysqldb.metrics.getStatus());
|
|
317
|
+
mysqldb.loglevel = 1;
|
|
318
|
+
await mysqldb.connect();
|
|
319
|
+
test(mysqldb);
|
|
215
320
|
}
|
|
216
321
|
|
|
322
|
+
async function testHanaDb() {
|
|
323
|
+
let creds = require("../creds/hana.json");
|
|
324
|
+
var hana = new HanaDB(creds);
|
|
325
|
+
console.log(hana.metrics.getStatus());
|
|
326
|
+
hana.loglevel = 1;
|
|
327
|
+
await hana.connect();
|
|
328
|
+
test(hana);
|
|
329
|
+
}
|
|
217
330
|
|
|
218
331
|
async function test(db) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
332
|
+
testCount++;
|
|
333
|
+
var gm = new Game("IndVSPak", Date.now(), "Dhoni", 67.33, "paid");
|
|
334
|
+
gm.completed = true;
|
|
335
|
+
gm.runs = ["a", "b"];
|
|
336
|
+
gm.extras = {
|
|
337
|
+
location: "India",
|
|
338
|
+
raining: false,
|
|
339
|
+
match: 1,
|
|
340
|
+
};
|
|
341
|
+
var res = await db.create("games", gm).catch((e) => {
|
|
342
|
+
if (!e.message.includes("duplicate")) {
|
|
343
|
+
throw e;
|
|
227
344
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
345
|
+
});
|
|
346
|
+
gm.id = Date.now();
|
|
347
|
+
res = await db.insert("games", gm);
|
|
348
|
+
gm.id = Date.now();
|
|
349
|
+
|
|
350
|
+
res = await db.insert("games", gm);
|
|
351
|
+
gm.amount = 1;
|
|
352
|
+
gm.id = Date.now();
|
|
353
|
+
|
|
354
|
+
res = await db.insert("games", gm);
|
|
355
|
+
res = await db.get("games", { amount: 1 });
|
|
356
|
+
res = await db.getOne("games", { amount: 1 });
|
|
357
|
+
res = await db.update("games", { amount: 1 }, { userid: "xxxx" });
|
|
358
|
+
res = await db.getOne("games", { userid: "xxxx" });
|
|
359
|
+
|
|
360
|
+
res = await db.insert(
|
|
361
|
+
"games",
|
|
362
|
+
new Game("IndVSPak1", Date.now(), "Dhoni", 100, "free")
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
res = await db.insert(
|
|
366
|
+
"games",
|
|
367
|
+
new Game("IndVSPak2", Date.now(), "Dhoni", 200, "free")
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
res = await db.insert(
|
|
371
|
+
"games",
|
|
372
|
+
new Game("IndVSPak3", Date.now(), "Dhoni", 300, "paid")
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
res = await db.insert(
|
|
376
|
+
"games",
|
|
377
|
+
new Game("IndVSPak4", Date.now(), "Dhoni", 400, "paid")
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
res = await db.get("games", undefined, {
|
|
381
|
+
sort: [
|
|
382
|
+
{ field: "timeStamp", order: "asc" },
|
|
383
|
+
{ field: "amount", order: "asc" },
|
|
384
|
+
],
|
|
385
|
+
limit: 5,
|
|
386
|
+
offset: 1,
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
res = await db.get(
|
|
390
|
+
"games",
|
|
391
|
+
{ type: "paid" },
|
|
392
|
+
{
|
|
393
|
+
sort: [
|
|
394
|
+
{ field: "amount", order: "desc" },
|
|
395
|
+
{ field: "timeStamp", order: "desc" },
|
|
396
|
+
],
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
res = await db.get(
|
|
401
|
+
"games",
|
|
402
|
+
{ amount: 400 },
|
|
403
|
+
{
|
|
404
|
+
apply: {
|
|
405
|
+
field: "timeStamp",
|
|
406
|
+
sort: "desc",
|
|
407
|
+
ineq: {
|
|
408
|
+
op: ">=",
|
|
409
|
+
value: 1,
|
|
263
410
|
},
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
411
|
+
},
|
|
412
|
+
sort: [
|
|
413
|
+
{ field: "amount", order: "asc" },
|
|
414
|
+
{ field: "timeStamp", order: "desc" },
|
|
415
|
+
],
|
|
416
|
+
limit: 2,
|
|
417
|
+
offset: 1,
|
|
418
|
+
}
|
|
419
|
+
);
|
|
267
420
|
|
|
268
|
-
|
|
269
|
-
|
|
421
|
+
res = await db.delete("games", { id: "IndVSPak1" });
|
|
422
|
+
res = await db.getOne("games", { id: "IndVSPak1" });
|
|
270
423
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
424
|
+
console.log("SQLite DB Tests Successfull");
|
|
425
|
+
console.log(db.metrics.getStatus());
|
|
426
|
+
checkTestsCompleted();
|
|
274
427
|
}
|
|
275
428
|
|
|
276
429
|
// testSqlite();
|
|
277
430
|
// testFireStore();
|
|
278
431
|
// testMongo();
|
|
279
432
|
// testOracleDb()
|
|
280
|
-
testMysqlDb()
|
|
433
|
+
// testMysqlDb();
|
|
434
|
+
testHanaDb();
|