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

133
Vistas
removing data in nested arrays in mongodb shell

i'm new in Nosql. i'm using Mongodb shell for the first time. i've seen other related solutions but non of them is working for me. i have an object that contains several nested arrays i want to remove the data that are not in 2016. the collection looks like this.

"_id" : ObjectId("58754aa6b10700f77b90c018"),
"results" : [
    {
        "series" : [
            {
                "name" : "light",
                "columns" : [
                    "time",
                    "agent_id",
                    "device_id",
                    "rpi_id",
                    "type",
                    "value"
                ],
                "values" : [
                    [
                        "1970-01-01T00:00:01.474264311Z",
                        null,
                        "2:1",
                        "b07882d6-5c28-597b-89f9-d250f74b0bad",
                        "light",
                        "231"
                    ],
                    [
                        "1970-01-01T00:00:01.474280348Z",
                        null,
                        "1:1",
                        "b07882d6-5c28-597b-89f9-d250f74b0bad",
                        "light",
                        "404"
                    ],
                    [
                        "1970-01-01T00:00:01.474280526Z",
                        null,
                        "2:1",
                        "b07882d6-5c28-597b-89f9-d250f74b0bad",
                        "light",
                        "239"
                    ],
                    [
                        "2016-12-21T23:36:32Z",
                        "fce19d9c-3bba-5b18-9854-f86776b47a9c",
                        "4",
                        null,
                        null,
                        "1019"
                    ],
                    [
                        "2016-12-21T23:36:56Z",
                        "fce19d9c-3bba-5b18-9854-f86776b47a9c",
                        "1",
                        null,
                        null,
                        "1023"
                    ],
                    [
                        "2016-12-21T23:37:00Z",
                        "fce19d9c-3bba-5b18-9854-f86776b47a9c",
                        "5",
                        null,
                        null,
                        "1022"
                    ]
                ]
            }
        ]
    }
]

for example i tried this query to find them but the result is the whole collection:

db.lights.find({"results.series.values": {$elemMatch : {$elemMatch: {$not : /^2016/} } } })

i'll be so grateful if anyone could answer it.

over 4 years ago · Santiago Trujillo
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