mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
I didn't do much to "modernize" the pg-native codebase other than running it through the standard eslint --fix that is applied to the rest of the code. There's some easy opportunities there to update it to es6 and so on...it still uses some pretty antiquated coding styles in places. This PR re-introduces the native tests on node v20, and updates test matrix to drop unsupported versions of node & add in node v22.
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
var Client = require('../')
|
|
var async = require('async')
|
|
|
|
var loop = function () {
|
|
var client = new Client()
|
|
|
|
var connect = function (cb) {
|
|
client.connect(cb)
|
|
}
|
|
|
|
var simpleQuery = function (cb) {
|
|
client.query('SELECT NOW()', cb)
|
|
}
|
|
|
|
var paramsQuery = function (cb) {
|
|
client.query('SELECT $1::text as name', ['Brian'], cb)
|
|
}
|
|
|
|
var prepared = function (cb) {
|
|
client.prepare('test', 'SELECT $1::text as name', 1, function (err) {
|
|
if (err) return cb(err)
|
|
client.execute('test', ['Brian'], cb)
|
|
})
|
|
}
|
|
|
|
var sync = function (cb) {
|
|
client.querySync('SELECT NOW()')
|
|
client.querySync('SELECT $1::text as name', ['Brian'])
|
|
client.prepareSync('boom', 'SELECT $1::text as name', 1)
|
|
client.executeSync('boom', ['Brian'])
|
|
setImmediate(cb)
|
|
}
|
|
|
|
var end = function (cb) {
|
|
client.end(cb)
|
|
}
|
|
|
|
var ops = [connect, simpleQuery, paramsQuery, prepared, sync, end]
|
|
|
|
var start = Date.now()
|
|
async.series(ops, function (err) {
|
|
if (err) throw err
|
|
console.log(Date.now() - start)
|
|
setImmediate(loop)
|
|
})
|
|
}
|
|
|
|
// on my machine this will consume memory up to about 50 megs of ram
|
|
// and then stabalize at that point
|
|
loop()
|