Yiğit Rüzgar
01/20/2021, 6:13 PMRichard Ward
01/20/2021, 7:24 PMprisma.category.findMany({
where: {
subcategory: {
none: {}
}
}
});
Yiğit Rüzgar
01/21/2021, 3:23 AMnikolasburk
const categories = await prisma.category.findMany({
where: {
subCategories: {
some: {},
},
},
})
With this data:
┌─────────┬────┬───────────┬──────────────────┐
│ (index) │ id │ name │ parentCategoryId │
├─────────┼────┼───────────┼──────────────────┤
│ 0 │ 1 │ 'Tech' │ null │
│ 1 │ 2 │ 'GraphQL' │ 1 │
│ 2 │ 3 │ 'DBs' │ 1 │
│ 3 │ 4 │ 'APIs' │ 1 │
It returns just the Tech
category because it's the only one that has subcategories in this dataset.
You can read more about some
, none
and every
in the docs here. We also have a dedicated help article about this here.nikolasburk
Yiğit Rüzgar
01/24/2021, 11:00 AM