nedb
nedb copied to clipboard
Sort criteria by array size
It would be nice to have an easy way to sort records based on length of an array field.
For example, if database stores planets, and each planet has field satellites with an array of satellite names, it would be nice to be able to get, let's say, top 3 planets with maximum number of satellites.
I found undoc feature! db.find({}).sort({"arr.$size":1}) WORKED! Hooray! But now next question: is it legally, to do that in production?