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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                    How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page