Review/백엔드 - 인스타그램 클론
[Prisma] $exists
조커린
2020. 2. 11. 23:13
prisma.$exists.~
: 특정 요소가 있는 지 존재여부를 판단해준다. 조건 작성 가능 (boolean)
where 필터를 인자로 받아 추출함
예시
1) id:~~~를 가진 유저가 있는 지 판단
const userExists = prisma.$exists.user({
id: 'cjli6tko8005t0a23fid7kke7',
})
2) description 에 graphql 이나 prisma가 있고 && 2018에 created 된 것
const linkExists = await prisma.$exists.link({
AND: [
{
OR: [
{
description_contains: 'graphql',
},
{
description_contains: 'prisma',
},
],
},
{
AND: [
{
createdAt_gt: '2017',
},
{
createdAt_lt: '2019',
},
],
},
],
})