M.Dagiya
M.Dagiya

Reputation: 203

Sequelize ORM performing two queries in one classMethod

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

Answers (1)

Shivam
Shivam

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

Related Questions