skip to Main Content

MongoDB – Get data in date sections from an array

I am new to MongoDB, I want to get data in sections from the array. { "name":"User name", "messages":[ { "message":"Message 1", "date":"2022-05-12T00:00:00.000Z" }, { "message":"Message 2", "date":"2022-05-12T00:00:00.000Z" }, { "message":"Message 3", "date":"2022-05-13T00:00:00.000Z" }, { "message":"Message 4", "date":"2022-05-13T00:00:00.000Z" }, {…

VIEW QUESTION

Mongodb – filter array based on ObjectId

So I have 2 arrays here, let say const users = [{_id:ObjectId("6274fb5b82bcc9b2ccc0a361"), name:p1, age:10}, {_id:ObjectId("6274fbc382bcc9b2ccc0a362"), name:p2, age:15}, {_id:ObjectId("6277a3d5b66c061096222bbd")}, name:p3, age:20]; const filterArray = [ObjectId("6274fbc382bcc9b2ccc0a362"),ObjectId("6277a3d5b66c061096222bbd")]; I want to filter result based on matching ObjectId, here's what I'm trying to do const…

VIEW QUESTION
Back To Top
Search