开发者

Subquery with Angular Sequelize error in VSCode at parentheses enclosing the subquery

开发者 https://www.devze.com 2022-12-07 20:03 出处:网络
Trying to use Sequelize with a subquery to filter results in an Angular Service in SQL clause. Account:

Trying to use Sequelize with a subquery to filter results in an Angular Service in SQL clause.

Account:
  accountId,
  accountName,
  accountAddress,
  ...

Equipment
  equipmentId
  equipmentName
  ...

accountEquipment
  accountId,
  equipmentId,
  accountEquipment Status,
  ...

Goal: to have a master list of equipment which an Account can select from to associate with their specific registered presence on my site while accommodating updates to the equipment definition to allow for spec updates to the master.

The SQL version would look like:

select * from equipment where equipment.equipmentId in 
    (select equipmentId from accountEquipment where accountId = 1 )
where the accountId is passed from the session context

I've tried multiple approaches with no luck. According to Sequelize docs, a raw query responding as an Angular service (https://sequelize.org/docs/v6/core-concepts/raw-queries/) would go something like:

const _thisData = await sequelize.query("
    select * from equi开发者_如何转开发pment
    where equipment.equipmentId in (
        select equipmentId from accountEquipment
        where accountId = 1)");

However, the subquery throws an error in VSCode at parentheses enclosing the subquery.

0

精彩评论

暂无评论...
验证码 换一张
取 消