如何在node.js上使用where语句的where语句

时间:2016-04-19 06:30:01

标签: angularjs node.js postgresql

enter image description here>我试图使用postgres数据库表提供包含电子邮件和密码的登录凭据。

  

postgres数据库表。当我得到记录时,它应该发送200状态   到我的页面。我的查询错误。请帮助我如何使用   选择条件。我错过了一些语法。

     getUser : function(req, res) {    
        var pg = require('pg');    
        var conString = process.env.DATABASE_URL || "postgres://test:test@localhost:5432/wallet";
        var client = new pg.Client(conString);  
          client.connect();

             console.log(req.query.email_id);
             console.log(req.query.user_password);
            var query = client.query("select * from pp_user_profile where email_id ="+req.query.email_id+ "and" + "user_password=" +req.query.password);

            query.on("end", function (result) {          
                client.end();
                res.writeHead(200, {'Content-Type': 'text/plain'});
                res.write('Success');
                res.end();  
            }); 

  },

1 个答案:

答案 0 :(得分:1)

尝试以下语法:

"select * from pp_user_profile where email_id  = '"+req.query.email_id+"' and user_password= '"+req.query.password+"'";