2016-02-27 69 views

回答

1

我會做那樣的事情。 (未測試)

var searchPromise = Promise.resolve(); 

searchPromise = db.Question.findAll({ 
    where: { 
    PassageId: dbPassage.id, 
    active: true, 
    level: { 
     $lte: startLevel, 
     $gte: endLevel 
    } 
    }, 
    order: [db.Sequelize.fn('RANDOM')] 
}).each(function(dbQuestion) { 
    if (condition === true) { 
    searchPromise.cancel(); 
    } 
}).cancellable();