Example:

I have a schema , and I am using prisma as th ORM to communicate to mongodb

model Category {
id           String       @id @default(auto()) @map("_id") @db.ObjectId
products     Product[]
}

type Product {
name                  String
popular               Boolean

}

collection would look like

 category =[
  {
    name: "Juice",
    products: [
      {
        name: "Mojito",
        popular: true,
      },
      {
        name: "Lemon mint",
        popular: false,
      },
    ],
  },

  {
    name: "Coffee",
    products: [
      {
        name: "Caramel",
        popular: true,
      },
      {
        name: " mint",
        popular: false,
      },
    ],
  }
];

question:
how to query category collection and filter out only the popular item

Result expected:

[
  {
    name: "Juice",
    products: [
      {
        name: "Mojito",
        popular: true,
      },
    ],
  },
  {
    name: "Coffee",
    products: [
      {
        name: "Caramel",
        popular: true,
      },
    ],
  },
];

how do I achieve this Prisma Client for Mongo db.
I tried to use where clause with ‘some’ operator. but it doesnt’ seem to be working.

 const categoriesWithPopularProduct = db.category.findMany({
    where: {
      products: {
        some: {
          popular: { equals: true },
        },
      },
    },
    
  });

The above query is returning all the products in the category. I want only the category with only the products which are popular.

can anybody help me.?