Say I have the following postgreSQL composite type:
CREATE TYPE myType AS(
id bigint,
name text,
);
and a stored procedure that excepts that type:
CREATE FUNCTION myFunction(mt myType){
//do some stuff
}
I would like to call this procedure from Node-js using node-postgres module.
var pg = require('pg');
var connectionString = "connection string";
pg.connect(connectionString, function(err, client, done) {
client.query('SELECT myFunction($1)', [some value],
function(err, result) {
// do stuff
done();
});
});
How do i create such a type in JS? Is there a way to pass a type from Node to a Postgres stored procedure?