Reputation: 203
Is performing two queries in one Sequelize model classMethod allowed? Like So.
Billings.getStartDateById = function(id){
Billings.getBuildingIdById(id).then(function(new_id){
return sequelize.query("select start_date from billings where id = ?",{
model:Billings,
replacements:[
new_id
],
type: sequelize.QueryTypes.SELECT
})
});
}
Upvotes: 0
Views: 133
Reputation: 3642
There is nothing stopping from doing it, if you have a valid usecase.
Also, you could use the sequelize find method instead of doing a raw query and you seem to be missing a return on line 2
Upvotes: 1