Einfache Erklärung, wenn Sie eine Mongo-Abfrage Antwort wie unten haben - und Sie nur den höchsten Wert von Array-> "Datum" wollen.
{
"_id": "57ee5a708e117c754915a2a2",
"TotalWishs": 3,
"Events": [
"57f805c866bf62f12edb8024"
],
"wish": [
"Cosmic Eldorado Mountain Bikes, 26-inch (Grey/White)",
"Asics Men's Gel-Nimbus 18 Black, Snow and Fiery Red Running Shoes - 10 UK/India (45 EU) (11 US)",
"Suunto Digital Black Dial Unisex Watch - SS018734000"
],
"Date": [
"2017-02-13T00:00:00.000Z",
"2017-03-05T00:00:00.000Z"
],
"UserDetails": [
{
"createdAt": "2016-09-30T12:28:32.773Z",
"jeenesFriends": [
"57edf8a96ad8f6ff453a384a",
"57ee516c8e117c754915a26b",
"58a1644b6c91d2af783770b0",
"57ef4631b97d81824cf54795"
],
"userImage": "user_profile/Male.png",
"email": "roopak@small-screen.com",
"fullName": "Roopak Kapoor"
}
],
},
*** Dann hast du hinzugefügt
Latest_Wish_CreatedDate: {$ max: "$ Date"},
so etwas wie unten-
{
$project : { _id: 1,
TotalWishs : 1 ,
wish:1 ,
Events:1,
Wish_CreatedDate:1,
Latest_Wish_CreatedDate: { $max: "$Date"},
}
}
Die endgültige Antwort auf die Abfrage finden Sie weiter unten
{
"_id": "57ee5a708e117c754915a2a2",
"TotalWishs": 3,
"Events": [
"57f805c866bf62f12edb8024"
],
"wish": [
"Cosmic Eldorado Mountain Bikes, 26-inch (Grey/White)",
"Asics Men's Gel-Nimbus 18 Black, Snow and Fiery Red Running Shoes - 10 UK/India (45 EU) (11 US)",
"Suunto Digital Black Dial Unisex Watch - SS018734000"
],
"Wish_CreatedDate": [
"2017-03-05T00:00:00.000Z",
"2017-02-13T00:00:00.000Z"
],
"UserDetails": [
{
"createdAt": "2016-09-30T12:28:32.773Z",
"jeenesFriends": [
"57edf8a96ad8f6ff453a384a",
"57ee516c8e117c754915a26b",
"58a1644b6c91d2af783770b0",
"57ef4631b97d81824cf54795"
],
"userImage": "user_profile/Male.png",
"email": "roopak@small-screen.com",
"fullName": "Roopak Kapoor"
}
],
"Latest_Wish_CreatedDate": "2017-03-05T00:00:00.000Z"
},