Thom
05/13/2022, 12:32 PMThom
05/13/2022, 12:35 PMThom
05/13/2022, 12:38 PMNurul
05/13/2022, 1:14 PMThom
05/13/2022, 1:23 PMThom
05/13/2022, 1:23 PMmodel Property {
id Int @id @default(autoincrement())
imageUrl String?
imageAlt String?
beds Int
baths Int
title String
description String
formattedPrice String
reviewCount Int
rating Int
tags Tag[]
}
model Tag {
id Int @id @default(autoincrement())
name String @unique
Properties Property[]
}Thom
05/13/2022, 1:27 PMNurul
05/13/2022, 2:49 PMconst result = await prisma.property.findMany({
include: {
tags: true,
},
where: {
tags: {
some: {
id: {
in: [1, 2, 3],
},
},
},
},
});
console.log("result", JSON.stringify(result, null, 2));
And Here's the output, both records having tags - 1,2,3 and tags-1,2,3,4 are fetched.
result [
{
"id": 1,
"imageUrl": null,
"imageAlt": "Testing",
"beds": 2,
"baths": 2,
"title": "Testing",
"description": "Testing",
"formattedPrice": "$100",
"reviewCount": 10,
"rating": 4,
"tags": [
{
"id": 1,
"name": "1"
},
{
"id": 2,
"name": "2"
},
{
"id": 3,
"name": "3"
}
]
},
{
"id": 4,
"imageUrl": null,
"imageAlt": "Testing 2",
"beds": 2,
"baths": 2,
"title": "Testing 2",
"description": "Testing 2",
"formattedPrice": "$100",
"reviewCount": 10,
"rating": 4,
"tags": [
{
"id": 1,
"name": "1"
},
{
"id": 2,
"name": "2"
},
{
"id": 3,
"name": "3"
},
{
"id": 5,
"name": "4"
}
]
}
]Thom
05/13/2022, 3:06 PMThom
05/13/2022, 5:32 PM