Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda