如何通过sequelize查询sql?

时间:2019-03-19 03:44:21

标签: node.js orm sequelize.js

SELECT DISTINCT product.id
FROM            productinfo product
LEFT JOIN       tagproduct tp
ON              tp.productid = product.id
LEFT JOIN       tags
ON              tags.id = tp.tagid
WHERE           product.status = 1
AND             (  product.deletedat IS NULL
                OR product.deletedat > Now() )
AND             EXISTS
                (
                   SELECT   Count(1)
                   FROM     tagproduct
                   WHERE    tagid IN (${tags})
                     AND    productid = product.id
                   GROUP BY productid
                   HAVING   count(1) >= ${tags.length} )

标签是标签表的id,我不知道如何将其转换为orm.find

0 个答案:

没有答案