querying to mongodb collection to pinning last 24 hour object always come first with condition
[
{
"panel":"mobile",
"createdAt":"2020-11-02T11:19:12+05:00"
},
{
"panel":"web",
"createdAt":"2020-11-02T11:16:12+05:00"
},
{
"panel":"mobile",
"createdAt":"2020-11-01T11:14:12+05:00"
},
{
"panel":"web",
"createdAt":"2020-11-02T11:13:12+05:00"
},
{
"panel":"web",
"createdAt":"2020-10-31T11:13:12+05:00"
}
]
I need to do the query to always come first of last 24 hour data with condition where panel="web"
The expected result will be like this
[
{
"panel":"web",
"createdAt":"2020-11-02T11:16:12+05:00"
},
{
"panel":"web",
"createdAt":"2020-11-02T11:13:12+05:00"
},
{
"panel":"mobile",
"createdAt":"2020-11-02T11:19:12+05:00"
},
{
"panel":"mobile",
"createdAt":"2020-11-01T11:14:12+05:00"
},
{
"panel":"web",
"createdAt":"2020-10-31T11:13:12+05:00"
}
]
let suppose if I have panel : "mobile" at 4:05 pm and panel: "web" at 3:05 pm I need panel: "web" at first and this condition only applicable for the last 24 hours I don't need to apply this with older.