Sequelize - How to execute queries in sequence?
<p>I'm using sequelize 3.24.3 to connect to a MySQL database.</p>

<p>My requirement is to: execute query 1 and then execute query 2 after query 1 completes. Below is the code sample</p>

<pre><code>Student.findOne({
    where:{
        userID:request.query.userID
    }
}).then(function(data){
    Papers.findAll({
            where:{
                userID:request.query.userID
            }
        }
    )
}).then(function (papers) {
    response.json({success: true,  paper: papers,});
}).catch(function (err) {
    console.log(err);
});
</code></pre>

<p>When the above runs: after findOne completes it calls the second "then" block and afterwards executes the findAll query. How can I prevent this and have it the queries executed sequentially?</p>