Skip to content

Misunderstanding something #40

Closed
Closed
@ghost

Description

I'm sure I'm just misunderstanding something, but should this not work? Variables defined outside the pg.connect scope are not visible within it? I feel like I must be missing something obvious. Any little advice would be great. Thanks.
function(){ var myResultStore = []; pg.connect(conString, function(err, client) { if(err) throw new Error('Could not connect to the database'); client.query("SELECT name FROM people LIMIT 2", function(err, result) { if(err) throw new Error('Query Failure'); result.rows.forEach(function(row){ myResultStore.push(row.name)}); console.log(myResultStore.toString()); // ** correctly returns [Bob, John] }); } console.log(myResultStore); // ** returns [] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions