node-pg-query-stream
node-pg-query-stream copied to clipboard
Should work with a QueryConfig
Hi Brianc, and thx for this great module !
Unlike pg.Client, QueryStream doesn't seem to work when a QueryConfig is passed, ie an object as :
{
text : 'SELECT * FROM foo WHERE bar =$1,
values : [1]
}
I get the following error :
Unhandled rejection TypeError: "string" must be a string, Buffer, or ArrayBuffer
at Function.byteLength (buffer.js:363:11)
at module.exports.Writer.addCString (C:\node-projects\payroll-app\node_modules\buffer-writer\index.js:57:22)
at Connection.parse (C:\node-projects\payroll-app\node_modules\pg\lib\connection.js:212:6)
at module.exports.Cursor.submit (C:\node-projects\payroll-app\node_modules\pg-query-stream\node_modules\pg-cursor\index.js:21:7)
at Client._pulseQueryQueue (C:\node-projects\payroll-app\node_modules\pg\lib\client.js:298:24)
at Client.query (C:\node-projects\payroll-app\node_modules\pg\lib\client.js:326:8)
Is it a bug or a this feature is missing ?
Thx by advance.
It's just a missing feature. :/ I need to support that, just haven't had the time yet.
I'm using sql-template in my source code which is really nice, so having this feature would be a big bonus. As a workaround I'm currently using:
const {text, values} = SQL`
SELECT
event_id,
user_id,
data->>'sessionDateTime' AS session_date_time,
data
FROM event
WHERE data->>'sessionDateTime' >= ${beginDateTime}
AND data->>'sessionDateTime' <= ${endDateTime}
`;
const query = new QueryStream(text, values)