Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Storing/updating deeply nested object array in mongodb

I have an array of object by the below format

{
    id: 1,
    text: "Group 1",
    complete: 35,
    start: "2021-10-04T00:00:00",
    end: "2021-10-16T00:00:00",
    taskOwner: "test owner 10",
    wbsNumber: "1",
    children: [
      {
        id: 2,
        start: "2021-10-04T00:00:00",
        end: "2021-10-11T00:00:00",
        text: "Task 1",
        complete: 60,
        children: [
          {
            id: 1113,
            start: "2021-10-11T00:00:00",
            end: "2021-10-16T00:00:00",
            text: "Task New",
            complete: 0,
          },
        ],
      },
    ],
  }

The children array can be nested N times. What is the best way to store/update this array in mongodb?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

From the official Mongo documentation:

MongoDB supports no more than 100 levels of nesting for BSON documents.

So if N could ever be expected to be larger than 100, then your Mongo driver would throw an error when you try to write. But assuming N would not be near this threshhold, then you may work with your data as you would with any other data.

One workaround here might be to use the GridFS collection to store your massively nested JSON objects. Your data would actually be stored as binary chunks. However, realize that querying and updated data in GridFS will tend to be much slower than using BSON documents in a regular Mongo collection. Before you go in the direction of GridFS, you might want to rethink your data model.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!