Created
April 10, 2015 08:27
-
-
Save LinZap/af02e797978618b4a9ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = require('pg-query'); | |
query.connectionParameters = 'postgres://postgres:[email protected]:5432/fba_db'; | |
var i=10; | |
//accepts optional array of values as 2nd parameter for parameterized queries | |
var promise; | |
q(); | |
function onSuccess(rows, result) { | |
i--; | |
console.log(rows[0].cname); | |
if(i>=0) q(); | |
} | |
function onError(error) { | |
console.log('ERROR'); | |
} | |
function q(){ | |
var sql = (i%2==0)? "select * from class limit 1":"select * from object limit 1"; | |
promise = query(sql); | |
promise.spread(onSuccess, onError); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment