1

I have got a collection of documents and each documents contains a nested array of objects.

{
  "id": "309324739",
  "debters": [
    {
      "user": {
        "name": "John Doe",
        "internal": true
      },
      "debt": 1463,
    },
    {
      "user": {
        "name": "Alex Tree",
        "internal": false
      },
      "debt": 53443,
    },
}

What I'm trying to do is to return find the document by id and then find inside the debters list that has a false flag?

I tried the following query...

Debters findByIdAndDebters_User_InternalIsFalse(@Param("id") String id,);

But I'm getting an error saying that it can find "internal" property. What am I doing wrong and how can I loop through array using this magic mongo repository query?

ignite-me
  • 738
  • 3
  • 14
  • 33

1 Answers1

0

you need to write a native query for that which is similar to @Query("{'debters.user.internal':false,'_id':''}") Debters findByIdAndDebtersUserInternalIsFalse(@Param("id") String id,);

Vipul Pandey
  • 1,507
  • 11
  • 20