I would like to have the number of views of a post that has been viewed the most. Below is a small example.
Users:
{
   username: "John"
},
{
   username: "Doe"
}
Messages:
{
   title: "Lorem Ipsum!",
   views: 400,
   author: "John"
},
{
   title: "Lorem Ipsum!",
   views: 200,
   author: "John"
},
{
   title: "Lorem Ipsum!",
   views: 100,
   author: "John"
},
{
   title: "Lorem Ipsum!",
   views: 403,
   author: "Doe"
},
{
   title: "Lorem Ipsum!",
   views: 299,
   author: "Doe"
},
I want to have a property for each user on the object that contains the highest number of views of a message. Like this:
{
   username: "John"
   highest_view: 400
},
{
   username: "Doe"
   highest_view: 403
}
I could solve this in code by looping through and querying each object, but that doesn't seem like the most convenient way.
 
    