notme
notme

Reputation: 461

Coffeescript, how do I pass variables in a function in this case?

I'm new to coffeescript and I'm stuck in a easy problem that I feel ashamed :S ...

How would you pass the variable query inside the function?

query = 'select * from blabla'
pg.connect conString, (err, client, done) ->
            client.query query, (err, result) ->
                    if err
                        console.log "error"
                    else
                        console.log "success"
                    done()

Upvotes: 1

Views: 115

Answers (1)

notme
notme

Reputation: 461

Found the issue. The real problem was probably that the name query was too generic :/ Solved with changing the name of the variable..

theQuery = 'select * from blabla'
pg.connect conString, (err, client, done) ->
            client.query theQuery, (err, result) ->
                    if err
                        console.log "error"
                    else
                        console.log "success"
                    done()

Upvotes: 1

Related Questions