MongoDB $in return in order? -
MongoDB $in return in order? -
this question has reply here:
order of responses mongodb $in query? [duplicate] 6 answerslet's i'm asking mongodb query this:
"somefield" : { "$in" : [9,3,7,1] }
will returned objects sorted order of $in array?
iow, when looking @ results, see documents {"somefield" : 9} listed before documents {"somefield":3 }, , 7's , 1's?
if not, tips on how that?
thanks!
unfortunately, not order of $in
array not impact order of results, there doesn't appear built-in way provide custom sorting function sort function. have implement own sorting function after retrieving results. if can tell language you're using query mongodb, help part (if needed).
mongodb
Comments
Post a Comment