Skip to content

Commit c1584de

Browse files
committed
Add 'ts-postgres' to benchmarks
1 parent 68a1b4b commit c1584de

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const queries = [
1010
'pg-promise-native',
1111
'pg',
1212
'pg-native',
13-
'slonik'
13+
'slonik',
14+
'ts-postgres'
1415
]
1516
, warmup = 3
1617
, iterations = 10000

package-lock.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
"author": "",
1010
"license": "ISC",
1111
"dependencies": {
12-
"pg": "8.5.1",
13-
"pg-native": "3.0.0",
14-
"pg-promise": "10.9.2",
15-
"postgres": "1.0.2",
16-
"slonik": "23.5.5"
12+
"generic-pool": "^3.9.0",
13+
"pg": "8.11.3",
14+
"pg-native": "3.0.1",
15+
"pg-promise": "11.5.5",
16+
"postgres": "3.4.4",
17+
"slonik": "39.3.0",
18+
"ts-postgres": "^2.0.1"
1719
}
1820
}

ts-postgres/index.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { connect } = require('ts-postgres')
2+
const { createPool } = require('generic-pool');
3+
4+
const pool = createPool(
5+
{
6+
create: connect,
7+
destroy: client => client.end()
8+
},
9+
{ max: 4 },
10+
);
11+
12+
const query = (text, values) => pool.use(async client => client.query(text, values))
13+
14+
module.exports = {
15+
queries: {
16+
select: () => query('select 1 as x'),
17+
select_arg: () => query('select $1 as x', [1]),
18+
select_args: () => query(`select
19+
$1::int as int,
20+
$2 as string,
21+
$3::timestamp with time zone as timestamp,
22+
$4 as null,
23+
$5::bool as boolean,
24+
$6::bytea as bytea,
25+
$7::jsonb as json
26+
`, [
27+
1337,
28+
'wat',
29+
new Date().toISOString(),
30+
null,
31+
false,
32+
Buffer.from('awesome'),
33+
[{ some: 'json' }, { array: 'object' }]
34+
]),
35+
select_where: () => query('select * from pg_catalog.pg_type where typname = $1', ['bool'])
36+
},
37+
end: () => Promise.all([pool.drain(), pool.clear()])
38+
}

0 commit comments

Comments
 (0)