0

Hi I'm a beginner and I have very little clue about trying to insert an array into an already existing one. I have the JSON structure here, and I'm trying to insert another array. I tried looking for it online but I couldn't find enough resources, for inserting data into a nested object.

{
  "mainbranch": "Assets",
  "childOfMainBranch": [
    {
      "mainbranch": "External Accounts",
      "childOfMainBranch": [
        {
          "mainbranch": "Cash and Cash Balances",
          "childOfMainBranch": [
            {
              "mainbranch": "Cash Reserve",
              "count": 1010131,
              "createdOn": "30-08-2020",
              "currency": "EUR",
              "createdBy": "Company A"
            },
            {
              "mainbranch": "Values Undergoing Collection",
              "count": 1012131,
              "createdOn": "31-09-2021",
              "currency": "EUR",
              "createdBy": "Company B"
            },
            {
              "mainbranch": "Bank Account Number",
              "count": 1022131,
              "createdOn": "14-05-2019",
              "currency": "EUR",
              "createdBy": "Company A"
            }
          ]
        }
      ]
    }
  ],
  "_class": "com.tree.model.Tree"
}
Dee
  • 1
  • You can use update/$push , few examples here: https://stackoverflow.com/questions/27874469/mongodb-push-in-nested-array – R2D2 Jan 29 '23 at 19:04

0 Answers0