D
D
Denis Denis2015-12-06 14:11:46
JavaScript
Denis Denis, 2015-12-06 14:11:46

How to return a promise?

With node.js I use MySQL
after getting the result from the database, I still have a lot to do

function sendToBase () {
    pool.getConnection(function (err, connection) {

        if(err) {
            debug(err);
            return err;
        }
        connection.query(querySQL, function (err, rows) {
            if (err) {
                debug(err);
            } else {
                // возвращаем соединение в пул
                connection.release();
              console.log(rows)  // Как вернуть столбцы?

            }
        });
    });
}

In all the rows examples, they print to the console. And how to return something to make a chain of promises?
Thanks :)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question