Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda