У меня много записей в коллекции комиссионных.
{
"_id": "5f2b96508082a30d27581cf7",
"createdAt": "2020-08-06T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Created",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2b996d8082a30d27581cf9",
"createdAt": "2020-08-05T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Pending",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2ba2e28082a30d27581cfe",
"createdAt": "2020-08-05T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Accepted",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2ba2ea8082a30d27581cff",
"createdAt": "2020-08-04T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Pending",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2ba2ea8082a30d27581cff",
"createdAt": "2020-08-03T03:34:08.281Z",
"supplierName": "John Cena",
"status": "Rejected",
"commissionID": "5f2b96508082a30d27581cf6"
}
Мне нужно отсортировать по статусу Pending и createdAt в des c (я имею в виду все ожидающие записи сверху с createdAt Date des c порядок)
status = Created , Pending, Accepted, Rejected
;
Должно быть так
{
"_id": "5f2b996d8082a30d27581cf9",
"createdAt": "2020-08-05T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Pending",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2ba2ea8082a30d27581cff",
"createdAt": "2020-08-04T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Pending",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2b96508082a30d27581cf7",
"createdAt": "2020-08-06T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Created",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2ba2e28082a30d27581cfe",
"createdAt": "2020-08-05T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Accepted",
"commissionID": "5f2b96508082a30d27581cf6"
},
{
"_id": "5f2ba2ea8082a30d27581cff",
"createdAt": "2020-08-03T05:34:08.281Z",
"supplierName": "John Cena",
"status": "Rejected",
"commissionID": "5f2b96508082a30d27581cf6"
}
Я использую mongodb 3.4, mon goose и node.js . Пожалуйста, помогите мне.