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

130
Views
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
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!