Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. checkPrice : function (giveListID, getListName, offer, user) {
  2. var client = new pg.Client(connectionString);
  3. var giveListPrice = [];
  4. var giveListPrices = function(id) {
  5. return new Promise(function(resolve, reject) {
  6. client.connect();
  7. var query = client.query("SELECT itemprice FROM ITEMS WHERE itemid = $1", [giveListID[itemID]]);
  8. query.on("row", function (row, result) {
  9. result.addRow(row);
  10. });
  11. query.on("end", function (result) {
  12. client.end( function() {
  13. console.log(result.rows[0].itemprice);
  14. giveListPrice.push(result.rows[0].itemprice)
  15. resolve("Done");
  16. });
  17. });
  18. });
  19. };
  20. for (itemID in giveListID) {
  21. var promise = giveListPrices(giveListID[itemID]);
  22. promise.then(function() {
  23. console.log(giveListPrice);
  24. });
  25. };
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement