0
let data = [
    {
        "_id": '101',
        "name": 'category_1',
        "subcategory": [
            {
                "_id": '201',
                "name": 'subCategory_1'
            },
            {
                "_id": '202',
                "name": 'subCategory_2',
                "subsubcategory": [
                    {
                        "_id": '301',
                        "name": 'subsubcategory_1'
                    },
                    {
                        "_id": '302',
                        "name": 'subsubcategory_2'
                    }
                ]
            }
        ]
    }
]

How can I change subsubcategory name ?

4
  • If the first subcategory object has a subsubcategory array you can try this. Commented Sep 25, 2021 at 11:35
  • Expanding on @J.F. 's comment, you can also filter on the subCategory name :Playground Commented Sep 25, 2021 at 19:13
  • Does this answer your question? how to update value in a nested array mongodb? Commented Sep 26, 2021 at 1:09
  • I have found the solution. Thank you so much. Commented Sep 28, 2021 at 5:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.