redwoodjs

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

和自甴很熟 提交于 2021-01-04 03:25:17
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

佐手、 提交于 2021-01-04 03:22:52
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

我的梦境 提交于 2021-01-04 03:22:10
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only