I have votes in my system, but I want to sort by some calculation of votes and freshness of the item.
I know that in SQL, it should be quite easy to do something like this – with GETDATE(), DATEDIFF() and a bit of math magic.
How would I go about doing this in Mongo? Will it require to use map-reduce? I remember hearing that map-reduce is blocking – so it’s not recommended for high-traffic website page queries?
Thank you
In MongoDB you can sort on the value of any of the fields in a document, but you can’t sort on a calculated value.
However, in this case, couldn’t you just sort on the date (descending) instead of the freshness? Wouldn’t that give the same sort order?