{"action":"created","issue":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/755","labels_url":"https://api.github.com/repos/brianc/node-postgres/issues/755/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-postgres/issues/755/comments","events_url":"https://api.github.com/repos/brianc/node-postgres/issues/755/events","html_url":"https://github.com/brianc/node-postgres/issues/755","id":65173291,"number":755,"title":"postgres composite type","user":{"login":"yaacovk","id":5462197,"avatar_url":"https://avatars.githubusercontent.com/u/5462197?v=3","gravatar_id":"","url":"https://api.github.com/users/yaacovk","html_url":"https://github.com/yaacovk","followers_url":"https://api.github.com/users/yaacovk/followers","following_url":"https://api.github.com/users/yaacovk/following{/other_user}","gists_url":"https://api.github.com/users/yaacovk/gists{/gist_id}","starred_url":"https://api.github.com/users/yaacovk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaacovk/subscriptions","organizations_url":"https://api.github.com/users/yaacovk/orgs","repos_url":"https://api.github.com/users/yaacovk/repos","events_url":"https://api.github.com/users/yaacovk/events{/privacy}","received_events_url":"https://api.github.com/users/yaacovk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-30T09:35:29Z","updated_at":"2015-03-30T13:17:39Z","closed_at":"2015-03-30T13:16:31Z","body":"Say I have the following postgreSQL composite type:\r\n\r\nCREATE TYPE myType AS(\r\n    id  bigint,\r\n    name  text,\r\n);\r\nand a stored procedure that excepts that type:\r\n\r\nCREATE FUNCTION myFunction(mt myType){\r\n   //do some stuff\r\n}\r\nI would like to call this procedure from Node-js using node-postgres module.\r\n\r\nvar pg = require('pg');\r\nvar connectionString = \"connection string\";\r\npg.connect(connectionString, function(err, client, done) {\r\n   client.query('SELECT myFunction($1)', [some value],   \r\n        function(err, result) {\r\n        // do stuff\r\n        done();\r\n    });\r\n});\r\nIs there a way to pass a type from Node to a Postgres stored procedure? \r\ndoes node-postgres support this kind of thing?"},"comment":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/comments/87673860","html_url":"https://github.com/brianc/node-postgres/issues/755#issuecomment-87673860","issue_url":"https://api.github.com/repos/brianc/node-postgres/issues/755","id":87673860,"user":{"login":"yaacovk","id":5462197,"avatar_url":"https://avatars.githubusercontent.com/u/5462197?v=3","gravatar_id":"","url":"https://api.github.com/users/yaacovk","html_url":"https://github.com/yaacovk","followers_url":"https://api.github.com/users/yaacovk/followers","following_url":"https://api.github.com/users/yaacovk/following{/other_user}","gists_url":"https://api.github.com/users/yaacovk/gists{/gist_id}","starred_url":"https://api.github.com/users/yaacovk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaacovk/subscriptions","organizations_url":"https://api.github.com/users/yaacovk/orgs","repos_url":"https://api.github.com/users/yaacovk/repos","events_url":"https://api.github.com/users/yaacovk/events{/privacy}","received_events_url":"https://api.github.com/users/yaacovk/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T13:17:39Z","updated_at":"2015-03-30T13:17:39Z","body":"Found the following  solution:\r\n\r\nvar pg = require('pg');\r\nvar connectionString = \"connection string\";\r\n\r\nvar myType = [\r\n  12345,\r\n  'you'\r\n];\r\npg.connect(connectionString, function(err, client, done) {\r\n   client.query('SELECT myFunction($1::myType)', \r\n     ['(' + myType.toString() + ')' ],   \r\n     function(err, result) {\r\n      // do stuff\r\n    done();\r\n});"}}