Find in Double Nested Array MongoDBMongoDB find value match for a property in array within array of objectsmongoose find by nested object ids return the entire documentFilter nested array in mongodb?How to Query for Embedded document in MongoDb?find in nested array pymongopython3 pymongo find and array_filtersMongoDB: Filtering a double nested array by list membershipGet exactly one object from 3 level nested schema in mongoDBmongodb filter on array inside arrayFilter subdocument in MongoDB

What is the word for reserving something for yourself before others do?

Font hinting is lost in Chrome-like browsers (for some languages )

Mathematical cryptic clues

What typically incentivizes a professor to change jobs to a lower ranking university?

The use of multiple foreign keys on same column in SQL Server

How is it possible to have an ability score that is less than 3?

Has the BBC provided arguments for saying Brexit being cancelled is unlikely?

Why do I get two different answers for this counting problem?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Why dont electromagnetic waves interact with each other?

Why doesn't H₄O²⁺ exist?

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)

How to write a macro that is braces sensitive?

Problem of parity - Can we draw a closed path made up of 20 line segments...

Can I make popcorn with any corn?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Service Entrance Breakers Rain Shield

What do you call a Matrix-like slowdown and camera movement effect?

Can divisibility rules for digits be generalized to sum of digits

What does it mean to describe someone as a butt steak?

How does one intimidate enemies without having the capacity for violence?

Why can't I see bouncing of a switch on an oscilloscope?

Risk of getting Chronic Wasting Disease (CWD) in the United States?



Find in Double Nested Array MongoDB


MongoDB find value match for a property in array within array of objectsmongoose find by nested object ids return the entire documentFilter nested array in mongodb?How to Query for Embedded document in MongoDb?find in nested array pymongopython3 pymongo find and array_filtersMongoDB: Filtering a double nested array by list membershipGet exactly one object from 3 level nested schema in mongoDBmongodb filter on array inside arrayFilter subdocument in MongoDB






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








14















I have this Collection in mongodb




"_id" : "777",
"someKey" : "someValue",
"someArray" : [

"name" : "name1",
"someNestedArray" : [

"name" : "value"
,

"name" : "delete me"

]

]



I want to find document based on someArray.someNestedArray.name
but i can't find any useful link all search result about update nested array
i am trying this but return nothing



db.mycollection.find("someArray.$.someNestedArray":"$elemMatch":"name":"1")
db.mycollection.find("someArray.$.someNestedArray.$.name":"1")


and Some thing else



how can i find by element in double nested array mongodb?










share|improve this question






























    14















    I have this Collection in mongodb




    "_id" : "777",
    "someKey" : "someValue",
    "someArray" : [

    "name" : "name1",
    "someNestedArray" : [

    "name" : "value"
    ,

    "name" : "delete me"

    ]

    ]



    I want to find document based on someArray.someNestedArray.name
    but i can't find any useful link all search result about update nested array
    i am trying this but return nothing



    db.mycollection.find("someArray.$.someNestedArray":"$elemMatch":"name":"1")
    db.mycollection.find("someArray.$.someNestedArray.$.name":"1")


    and Some thing else



    how can i find by element in double nested array mongodb?










    share|improve this question


























      14












      14








      14


      9






      I have this Collection in mongodb




      "_id" : "777",
      "someKey" : "someValue",
      "someArray" : [

      "name" : "name1",
      "someNestedArray" : [

      "name" : "value"
      ,

      "name" : "delete me"

      ]

      ]



      I want to find document based on someArray.someNestedArray.name
      but i can't find any useful link all search result about update nested array
      i am trying this but return nothing



      db.mycollection.find("someArray.$.someNestedArray":"$elemMatch":"name":"1")
      db.mycollection.find("someArray.$.someNestedArray.$.name":"1")


      and Some thing else



      how can i find by element in double nested array mongodb?










      share|improve this question
















      I have this Collection in mongodb




      "_id" : "777",
      "someKey" : "someValue",
      "someArray" : [

      "name" : "name1",
      "someNestedArray" : [

      "name" : "value"
      ,

      "name" : "delete me"

      ]

      ]



      I want to find document based on someArray.someNestedArray.name
      but i can't find any useful link all search result about update nested array
      i am trying this but return nothing



      db.mycollection.find("someArray.$.someNestedArray":"$elemMatch":"name":"1")
      db.mycollection.find("someArray.$.someNestedArray.$.name":"1")


      and Some thing else



      how can i find by element in double nested array mongodb?







      mongodb mongodb-query aggregation-framework






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 30 '17 at 9:15









      Neil Lunn

      101k23179187




      101k23179187










      asked Mar 16 '15 at 7:39









      user298582user298582

      3691414




      3691414






















          2 Answers
          2






          active

          oldest

          votes


















          40
















          In the simplest sense this just follows the basic form of "dot notation" as used by MongoDB. That will work regardless of which array member the inner array member is in, as long as it matches a value:



          db.mycollection.find(
          "someArray.someNestedArray.name": "value"
          )


          That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch:



          db.mycollection.find(
          "someArray":
          "$elemMatch":
          "name": "name1",
          "someNestedArray":
          "$elemMatch":
          "name": "value",
          "otherField": 1




          )


          That matches the document which would contain something with a a field at that "path" matching the value. If you intended to "match and filter" the result so only the matched element was returned, this is not possible with the positional operator projection, as quoted:




          Nested Arrays



          The positional $ operator cannot be used for queries which traverse more than one array, such as queries that traverse arrays nested within other arrays, because the replacement for the $ placeholder is a single value




          Modern MongoDB



          We can do this by applying $filter and $map here. The $map is really needed because the "inner" array can change as a result of the "filtering", and the "outer" array of course does not match the conditions when the "inner" was stripped of all elements.



          Again following the example of actually having multiple properties to match within each array:



          db.mycollection.aggregate([
          "$match":
          "someArray":
          "$elemMatch":
          "name": "name1",
          "someNestedArray":
          "$elemMatch":
          "name": "value",
          "otherField": 1




          ,
          "$addFields":
          "someArray":
          "$filter":
          "input":
          "$map":
          "input": "$someArray",
          "as": "sa",
          "in":
          "name": "$$sa.name",
          "someNestedArray":
          "$filter":
          "input": "$$sa.someNestedArray",
          "as": "sn",
          "cond":
          "$and": [
          "$eq": [ "$$sn.name", "value" ] ,
          "$eq": [ "$$sn.otherField", 1 ]
          ]




          ,
          ,
          "as": "sa",
          "cond":
          "$and": [
          "$eq": [ "$$sa.name", "name1" ] ,
          "$gt": [ "$size": "$$sa.someNestedArray" , 0 ]
          ]




          ])


          Therefore on the "outer" array the $filter actually looks at the $size of the "inner" array after it was "filtered" itself, so you can reject those results when the whole inner array does in fact match noting.



          Older MongoDB



          In order to "project" only the matched element, you need the .aggregate() method:



          db.mycollection.aggregate([
          // Match possible documents
          "$match":
          "someArray.someNestedArray.name": "value"
          ,

          // Unwind each array
          "$unwind": "$someArray" ,
          "$unwind": "$someArray.someNestedArray" ,

          // Filter just the matching elements
          "$match":
          "someArray.someNestedArray.name": "value"
          ,

          // Group to inner array
          "$group":
          "_id":
          "_id": "$_id",
          "name": "$someArray.name"
          ,
          "someKey": "$first": "$someKey" ,
          "someNestedArray": "$push": "$someArray.someNestedArray"
          ,

          // Group to outer array
          "$group":
          "_id": "$_id._id",
          "someKey": "$first": "$someKey" ,
          "someArray": "$push":
          "name": "$_id.name",
          "someNestedArray": "$someNestedArray"


          ])


          That allows you to "filter" the matches in nested arrays for one or more results within the document.






          share|improve this answer

























          • Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

            – Sravan
            Oct 10 '17 at 11:26



















          0














          You can also try something like below:



          db.collection.aggregate(
          $unwind: '$someArray' ,

          $project:
          'filteredValue':
          $filter:
          input: "$someArray.someNestedArray",
          as: "someObj",
          cond: $eq: [ '$$someObj.name', 'delete me' ]




          )





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29071748%2ffind-in-double-nested-array-mongodb%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            40
















            In the simplest sense this just follows the basic form of "dot notation" as used by MongoDB. That will work regardless of which array member the inner array member is in, as long as it matches a value:



            db.mycollection.find(
            "someArray.someNestedArray.name": "value"
            )


            That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch:



            db.mycollection.find(
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            )


            That matches the document which would contain something with a a field at that "path" matching the value. If you intended to "match and filter" the result so only the matched element was returned, this is not possible with the positional operator projection, as quoted:




            Nested Arrays



            The positional $ operator cannot be used for queries which traverse more than one array, such as queries that traverse arrays nested within other arrays, because the replacement for the $ placeholder is a single value




            Modern MongoDB



            We can do this by applying $filter and $map here. The $map is really needed because the "inner" array can change as a result of the "filtering", and the "outer" array of course does not match the conditions when the "inner" was stripped of all elements.



            Again following the example of actually having multiple properties to match within each array:



            db.mycollection.aggregate([
            "$match":
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            ,
            "$addFields":
            "someArray":
            "$filter":
            "input":
            "$map":
            "input": "$someArray",
            "as": "sa",
            "in":
            "name": "$$sa.name",
            "someNestedArray":
            "$filter":
            "input": "$$sa.someNestedArray",
            "as": "sn",
            "cond":
            "$and": [
            "$eq": [ "$$sn.name", "value" ] ,
            "$eq": [ "$$sn.otherField", 1 ]
            ]




            ,
            ,
            "as": "sa",
            "cond":
            "$and": [
            "$eq": [ "$$sa.name", "name1" ] ,
            "$gt": [ "$size": "$$sa.someNestedArray" , 0 ]
            ]




            ])


            Therefore on the "outer" array the $filter actually looks at the $size of the "inner" array after it was "filtered" itself, so you can reject those results when the whole inner array does in fact match noting.



            Older MongoDB



            In order to "project" only the matched element, you need the .aggregate() method:



            db.mycollection.aggregate([
            // Match possible documents
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Unwind each array
            "$unwind": "$someArray" ,
            "$unwind": "$someArray.someNestedArray" ,

            // Filter just the matching elements
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Group to inner array
            "$group":
            "_id":
            "_id": "$_id",
            "name": "$someArray.name"
            ,
            "someKey": "$first": "$someKey" ,
            "someNestedArray": "$push": "$someArray.someNestedArray"
            ,

            // Group to outer array
            "$group":
            "_id": "$_id._id",
            "someKey": "$first": "$someKey" ,
            "someArray": "$push":
            "name": "$_id.name",
            "someNestedArray": "$someNestedArray"


            ])


            That allows you to "filter" the matches in nested arrays for one or more results within the document.






            share|improve this answer

























            • Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

              – Sravan
              Oct 10 '17 at 11:26
















            40
















            In the simplest sense this just follows the basic form of "dot notation" as used by MongoDB. That will work regardless of which array member the inner array member is in, as long as it matches a value:



            db.mycollection.find(
            "someArray.someNestedArray.name": "value"
            )


            That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch:



            db.mycollection.find(
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            )


            That matches the document which would contain something with a a field at that "path" matching the value. If you intended to "match and filter" the result so only the matched element was returned, this is not possible with the positional operator projection, as quoted:




            Nested Arrays



            The positional $ operator cannot be used for queries which traverse more than one array, such as queries that traverse arrays nested within other arrays, because the replacement for the $ placeholder is a single value




            Modern MongoDB



            We can do this by applying $filter and $map here. The $map is really needed because the "inner" array can change as a result of the "filtering", and the "outer" array of course does not match the conditions when the "inner" was stripped of all elements.



            Again following the example of actually having multiple properties to match within each array:



            db.mycollection.aggregate([
            "$match":
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            ,
            "$addFields":
            "someArray":
            "$filter":
            "input":
            "$map":
            "input": "$someArray",
            "as": "sa",
            "in":
            "name": "$$sa.name",
            "someNestedArray":
            "$filter":
            "input": "$$sa.someNestedArray",
            "as": "sn",
            "cond":
            "$and": [
            "$eq": [ "$$sn.name", "value" ] ,
            "$eq": [ "$$sn.otherField", 1 ]
            ]




            ,
            ,
            "as": "sa",
            "cond":
            "$and": [
            "$eq": [ "$$sa.name", "name1" ] ,
            "$gt": [ "$size": "$$sa.someNestedArray" , 0 ]
            ]




            ])


            Therefore on the "outer" array the $filter actually looks at the $size of the "inner" array after it was "filtered" itself, so you can reject those results when the whole inner array does in fact match noting.



            Older MongoDB



            In order to "project" only the matched element, you need the .aggregate() method:



            db.mycollection.aggregate([
            // Match possible documents
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Unwind each array
            "$unwind": "$someArray" ,
            "$unwind": "$someArray.someNestedArray" ,

            // Filter just the matching elements
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Group to inner array
            "$group":
            "_id":
            "_id": "$_id",
            "name": "$someArray.name"
            ,
            "someKey": "$first": "$someKey" ,
            "someNestedArray": "$push": "$someArray.someNestedArray"
            ,

            // Group to outer array
            "$group":
            "_id": "$_id._id",
            "someKey": "$first": "$someKey" ,
            "someArray": "$push":
            "name": "$_id.name",
            "someNestedArray": "$someNestedArray"


            ])


            That allows you to "filter" the matches in nested arrays for one or more results within the document.






            share|improve this answer

























            • Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

              – Sravan
              Oct 10 '17 at 11:26














            40












            40








            40









            In the simplest sense this just follows the basic form of "dot notation" as used by MongoDB. That will work regardless of which array member the inner array member is in, as long as it matches a value:



            db.mycollection.find(
            "someArray.someNestedArray.name": "value"
            )


            That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch:



            db.mycollection.find(
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            )


            That matches the document which would contain something with a a field at that "path" matching the value. If you intended to "match and filter" the result so only the matched element was returned, this is not possible with the positional operator projection, as quoted:




            Nested Arrays



            The positional $ operator cannot be used for queries which traverse more than one array, such as queries that traverse arrays nested within other arrays, because the replacement for the $ placeholder is a single value




            Modern MongoDB



            We can do this by applying $filter and $map here. The $map is really needed because the "inner" array can change as a result of the "filtering", and the "outer" array of course does not match the conditions when the "inner" was stripped of all elements.



            Again following the example of actually having multiple properties to match within each array:



            db.mycollection.aggregate([
            "$match":
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            ,
            "$addFields":
            "someArray":
            "$filter":
            "input":
            "$map":
            "input": "$someArray",
            "as": "sa",
            "in":
            "name": "$$sa.name",
            "someNestedArray":
            "$filter":
            "input": "$$sa.someNestedArray",
            "as": "sn",
            "cond":
            "$and": [
            "$eq": [ "$$sn.name", "value" ] ,
            "$eq": [ "$$sn.otherField", 1 ]
            ]




            ,
            ,
            "as": "sa",
            "cond":
            "$and": [
            "$eq": [ "$$sa.name", "name1" ] ,
            "$gt": [ "$size": "$$sa.someNestedArray" , 0 ]
            ]




            ])


            Therefore on the "outer" array the $filter actually looks at the $size of the "inner" array after it was "filtered" itself, so you can reject those results when the whole inner array does in fact match noting.



            Older MongoDB



            In order to "project" only the matched element, you need the .aggregate() method:



            db.mycollection.aggregate([
            // Match possible documents
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Unwind each array
            "$unwind": "$someArray" ,
            "$unwind": "$someArray.someNestedArray" ,

            // Filter just the matching elements
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Group to inner array
            "$group":
            "_id":
            "_id": "$_id",
            "name": "$someArray.name"
            ,
            "someKey": "$first": "$someKey" ,
            "someNestedArray": "$push": "$someArray.someNestedArray"
            ,

            // Group to outer array
            "$group":
            "_id": "$_id._id",
            "someKey": "$first": "$someKey" ,
            "someArray": "$push":
            "name": "$_id.name",
            "someNestedArray": "$someNestedArray"


            ])


            That allows you to "filter" the matches in nested arrays for one or more results within the document.






            share|improve this answer

















            In the simplest sense this just follows the basic form of "dot notation" as used by MongoDB. That will work regardless of which array member the inner array member is in, as long as it matches a value:



            db.mycollection.find(
            "someArray.someNestedArray.name": "value"
            )


            That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch:



            db.mycollection.find(
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            )


            That matches the document which would contain something with a a field at that "path" matching the value. If you intended to "match and filter" the result so only the matched element was returned, this is not possible with the positional operator projection, as quoted:




            Nested Arrays



            The positional $ operator cannot be used for queries which traverse more than one array, such as queries that traverse arrays nested within other arrays, because the replacement for the $ placeholder is a single value




            Modern MongoDB



            We can do this by applying $filter and $map here. The $map is really needed because the "inner" array can change as a result of the "filtering", and the "outer" array of course does not match the conditions when the "inner" was stripped of all elements.



            Again following the example of actually having multiple properties to match within each array:



            db.mycollection.aggregate([
            "$match":
            "someArray":
            "$elemMatch":
            "name": "name1",
            "someNestedArray":
            "$elemMatch":
            "name": "value",
            "otherField": 1




            ,
            "$addFields":
            "someArray":
            "$filter":
            "input":
            "$map":
            "input": "$someArray",
            "as": "sa",
            "in":
            "name": "$$sa.name",
            "someNestedArray":
            "$filter":
            "input": "$$sa.someNestedArray",
            "as": "sn",
            "cond":
            "$and": [
            "$eq": [ "$$sn.name", "value" ] ,
            "$eq": [ "$$sn.otherField", 1 ]
            ]




            ,
            ,
            "as": "sa",
            "cond":
            "$and": [
            "$eq": [ "$$sa.name", "name1" ] ,
            "$gt": [ "$size": "$$sa.someNestedArray" , 0 ]
            ]




            ])


            Therefore on the "outer" array the $filter actually looks at the $size of the "inner" array after it was "filtered" itself, so you can reject those results when the whole inner array does in fact match noting.



            Older MongoDB



            In order to "project" only the matched element, you need the .aggregate() method:



            db.mycollection.aggregate([
            // Match possible documents
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Unwind each array
            "$unwind": "$someArray" ,
            "$unwind": "$someArray.someNestedArray" ,

            // Filter just the matching elements
            "$match":
            "someArray.someNestedArray.name": "value"
            ,

            // Group to inner array
            "$group":
            "_id":
            "_id": "$_id",
            "name": "$someArray.name"
            ,
            "someKey": "$first": "$someKey" ,
            "someNestedArray": "$push": "$someArray.someNestedArray"
            ,

            // Group to outer array
            "$group":
            "_id": "$_id._id",
            "someKey": "$first": "$someKey" ,
            "someArray": "$push":
            "name": "$_id.name",
            "someNestedArray": "$someNestedArray"


            ])


            That allows you to "filter" the matches in nested arrays for one or more results within the document.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 30 '17 at 9:15

























            answered Mar 16 '15 at 8:03









            Neil LunnNeil Lunn

            101k23179187




            101k23179187












            • Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

              – Sravan
              Oct 10 '17 at 11:26


















            • Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

              – Sravan
              Oct 10 '17 at 11:26

















            Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

            – Sravan
            Oct 10 '17 at 11:26






            Thanks, That is fine for a "single field" value, for matching multiple-fields you would use $elemMatch this line clarified me the exact use of elemMatch,

            – Sravan
            Oct 10 '17 at 11:26














            0














            You can also try something like below:



            db.collection.aggregate(
            $unwind: '$someArray' ,

            $project:
            'filteredValue':
            $filter:
            input: "$someArray.someNestedArray",
            as: "someObj",
            cond: $eq: [ '$$someObj.name', 'delete me' ]




            )





            share|improve this answer



























              0














              You can also try something like below:



              db.collection.aggregate(
              $unwind: '$someArray' ,

              $project:
              'filteredValue':
              $filter:
              input: "$someArray.someNestedArray",
              as: "someObj",
              cond: $eq: [ '$$someObj.name', 'delete me' ]




              )





              share|improve this answer

























                0












                0








                0







                You can also try something like below:



                db.collection.aggregate(
                $unwind: '$someArray' ,

                $project:
                'filteredValue':
                $filter:
                input: "$someArray.someNestedArray",
                as: "someObj",
                cond: $eq: [ '$$someObj.name', 'delete me' ]




                )





                share|improve this answer













                You can also try something like below:



                db.collection.aggregate(
                $unwind: '$someArray' ,

                $project:
                'filteredValue':
                $filter:
                input: "$someArray.someNestedArray",
                as: "someObj",
                cond: $eq: [ '$$someObj.name', 'delete me' ]




                )






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 18 at 12:19









                JitendraJitendra

                1,099622




                1,099622



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29071748%2ffind-in-double-nested-array-mongodb%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme