数据库查询node.js(PHP风格)

我终于明白了websockets的概念。 我在这里find了很棒的问答,非常感谢。 我将要安装node.js以及apache和geoserver作为web-mapping项目,我将使用node.js来处理websocket。 实际上,在编码方面,我对php有更多的经验,并且很难将我的逻辑从传统的xml-http请求中转移出来,但我会给它一个机会。

一些问题,在我挖掘之前。我使用postgreSQL / postGIS,如何执行从node.js到postgreSQL / postGIS的数据库查询? 我习惯于像下面这样的传统的PHP查询

$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) 

大多数教程都谈论聊天应用程序,但是关于查询和与postgreSQL / postGIS沟通呢? 在node.js / socket.io中可以吗? 任何提示/教程? 我想执行查询,收集结果,把一些html标签,然后推回到客户端,在一个特定的股利。

另外,是node.js现在在Windows 7上工作,没有问题? 在过去它没有,但我想现在它,因为他们有一个MSI安装程序。 对?

非常感谢你…

使用节点Postgres https://github.com/brianc/node-postgres/文档非常好,易于使用。

它还允许使用格式准备好的语句

 query( {name:"emp_name", text:"select name from emp where emp_id=$1", values:[123]} )