nedb icon indicating copy to clipboard operation
nedb copied to clipboard

Sort criteria by array size

Open ovk opened this issue 9 years ago • 1 comments

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.

ovk avatar Jan 17 '16 19:01 ovk

I found undoc feature! db.find({}).sort({"arr.$size":1}) WORKED! Hooray! But now next question: is it legally, to do that in production?

impfromliga avatar Feb 03 '19 18:02 impfromliga