Postgresql query problems for nodejs

I am making an app with node.js, using the express framwork, woth postgresql as my database.

I have to insert some values into my database, and some of them have quotes. e.g. Tony's Seafood Restaurant. I cannot insert values like this.

I tried

name.replace('\'', '\\\'');

and also

name.replace("'", "\'");

but no success.

Problem is the postgresql server formats queries before running them. If the query look like this in my code,

insert into venues values (nextval('venue_venueid_seq'),'"+name+"','"+api+"','"+location+"','"+latitude+"','"+longitude+"','"+category+"','"+category_generalized+"')

then postgresql formats it like this (i found it by printing the client.query object)

insert into venues values (nextval(\'venue_venueid_seq\'),\'Tony\'s Seafood Restaurant\',\'Google Places\',\'18863 California 1, Marshall\',\'38.146777\',\'-122.882987\',\'restaurant,food,establishment\',\'Eatery,Eatery,establishment\')

You see postgresql already places slashes before the starting and the ending quotes of my string, so the escape slashes I programatically inserted in the middle of the string are not working.

How can I insert values like this? Please help.