I finally understood the concept of websockets. I found great Q/As here, helped a lot, thanks. I am about to install node.js alongside apache and geoserver for a web-mapping project, I'll use node.js just to handle websockets. In practice, coding-wise, I'm more experienced with php and its hard for me to shift my logic from traditional xml-http-requests, but I'll give it a shot.
Some questions, before I dig in. I use postgreSQL/postGIS, how can I perform database queries from node.js to postgreSQL/postGIS? I'm used to the traditional PHP queries like the following
$stmt = $dbh->prepare("SELECT pins.p_name FROM pins
WHERE type.t_id=pins.p_type AND
AND p_id = :nm");
$stmt->bindParam(':nm', $nm, PDO::PARAM_STR);
$nm=$jas;
$data=array('nm'=>$nm);
$stmt->execute($data);
//blah blah
//(I always use PDO and prepared statements)
Most tutorials out there talk about chat apps, but what about queries and communicating with postgreSQL/postGIS? Is that possible in node.js/socket.io? Any tips/tutorials? I want to execute the query, gather the outcome, put some html tags and then push it back to the client, in a specific div.
Also, is node.js now working on windows 7, without a problem? In the past it did not, but I guess now it does, since they have an msi installer. Right?
Thank you very much...
Use Node Postgres https://github.com/brianc/node-postgres/ The documentation is excellent and easy to use.
It also allows for prepared statements with the format
query( {name:"emp_name", text:"select name from emp where emp_id=$1", values:[123]} )