Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const queries = [
'pg-promise-native',
'pg',
'pg-native',
'slonik'
'slonik',
'ts-postgres'
]
, warmup = 3
, iterations = 10000
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
"author": "",
"license": "ISC",
"dependencies": {
"generic-pool": "^3.9.0",
"pg": "8.5.1",
"pg-native": "3.0.0",
"pg-promise": "10.9.2",
"postgres": "1.0.2",
"slonik": "23.5.5"
"slonik": "23.5.5",
"ts-postgres": "2.0.1"
}
}
38 changes: 38 additions & 0 deletions ts-postgres/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const { connect } = require('ts-postgres')
const { createPool } = require('generic-pool');

const pool = createPool(
{
create: connect,
destroy: client => client.end()
},
{ max: 4 },
);

const query = (text, values) => pool.use(async client => client.query(text, values))

module.exports = {
queries: {
select: () => query('select 1 as x'),
select_arg: () => query('select $1 as x', [1]),
select_args: () => query(`select
$1::int as int,
$2 as string,
$3::timestamp with time zone as timestamp,
$4 as null,
$5::bool as boolean,
$6::bytea as bytea,
$7::jsonb as json
`, [
1337,
'wat',
new Date().toISOString(),
null,
false,
Buffer.from('awesome'),
[{ some: 'json' }, { array: 'object' }]
]),
select_where: () => query('select * from pg_catalog.pg_type where typname = $1', ['bool'])
},
end: () => Promise.all([pool.drain(), pool.clear()])
}