0

I am new to this node.js and postgres database. I have done everything perfect querying and getting result. My problem is that when I am running select query in pgAdmin I am getting some 100 rows as output..

My code:

app.get('/reconcile', function(req, res){

var villagename = req.query.query;
var village=name.substring(0,4);
console.log("sub="+village);
console.log("select * from xxxxxxxxx where level4 ILIKE '%"+village+"%'")
   var  query = client.query("select * from tn_village where level4 ILIKE '%"+village+"%'");
   query.on('row', function(rows) {  
   res.send(rows);
});
});

What i want to achieve is .Suppose consider i am searching for "Apple" i am getting words matching "APP" form database by using above(Like) command..Now its showing json as alphabetical order..I want to display json as highest to lowest matching data in Json..

Help me to achieve this..Thanks in advance..

1 Answer 1

1

query.on('row', …) executes the callback for every row. Use

client.query('…', function(err, result) {
  done();
  res.send(result);
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @ckruse..Its working..But i am facing other problem.. 1)Its returning json for all rows and also printing fields and parsers..I don't want that..I have to display only the rows.. 2)Also How can i remove the files with null value..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.