-
-
Notifications
You must be signed in to change notification settings - Fork 610
/
of.ts
83 lines (67 loc) · 2.04 KB
/
of.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { mysqlp as mysql } from '../../../index.js';
import { access, uriAccess, sql, sqlPS, values } from '../../baseConnection.js';
const poolCluster = mysql.createPoolCluster();
poolCluster.add('cluster1', uriAccess);
poolCluster.add('cluster2', access);
/** execute */
(async () => {
const conn = poolCluster.of('cluster1');
{
/** Overload: execute(sql) */
const [results, fields] = await conn.execute(sql);
console.log(results, fields);
}
{
/** Overload: execute(sql, values) */
const [results, fields] = await conn.execute(sqlPS, values);
console.log(results, fields);
}
{
/** Overload: execute(QueryOptions) I */
const [results, fields] = await conn.execute({ sql });
console.log(results, fields);
}
{
/** Overload: execute(QueryOptions) II */
const [results, fields] = await conn.execute({ sql: sqlPS, values });
console.log(results, fields);
}
{
/** Overload: execute(QueryOptions, values) */
const [results, fields] = await conn.execute({ sql: sqlPS }, values);
console.log(results, fields);
}
/** @ts-expect-error: PoolNamespace can't be a `PoolConnection` */
conn.release();
})();
/** query */
(async () => {
const conn = poolCluster.of('cluster2');
{
/** Overload: query(sql) */
const [results, fields] = await conn.query(sql);
console.log(results, fields);
}
{
/** Overload: query(sql, values) */
const [results, fields] = await conn.query(sqlPS, values);
console.log(results, fields);
}
{
/** Overload: query(QueryOptions) I */
const [results, fields] = await conn.query({ sql });
console.log(results, fields);
}
{
/** Overload: query(QueryOptions) II */
const [results, fields] = await conn.query({ sql: sqlPS, values });
console.log(results, fields);
}
{
/** Overload: query(QueryOptions, values) */
const [results, fields] = await conn.query({ sql: sqlPS }, values);
console.log(results, fields);
}
/** @ts-expect-error: PoolNamespace can't be a `PoolConnection` */
conn.release();
})();