Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- checkPrice : function (giveListID, getListName, offer, user) {
- var client = new pg.Client(connectionString);
- var giveListPrice = [];
- var giveListPrices = function(id) {
- return new Promise(function(resolve, reject) {
- client.connect();
- var query = client.query("SELECT itemprice FROM ITEMS WHERE itemid = $1", [giveListID[itemID]]);
- query.on("row", function (row, result) {
- result.addRow(row);
- });
- query.on("end", function (result) {
- client.end( function() {
- console.log(result.rows[0].itemprice);
- giveListPrice.push(result.rows[0].itemprice)
- resolve("Done");
- });
- });
- });
- };
- for (itemID in giveListID) {
- var promise = giveListPrices(giveListID[itemID]);
- promise.then(function() {
- console.log(giveListPrice);
- });
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement