Sort Documents Without Existing Field to End of Results
问题 I have the following documents, few documents only have bids fields. Collection: { "_id" : "PqwSsLb2jsqTycMWR", "name" : "aaa", "bids" : [ { "amount" : NumberInt(450) } ] } { "_id" : "93EDoQfeYEFk8pyzX", "name" : "bbb" } { "_id" : "j5wkK5Eagnwuo8Jym", "name" : "ccc", "bids" : [ { "amount" : NumberInt(520) } ] } { "_id" : "eLaTyM5h5kqA97WQQ", "name" : "ddd" } If I sort with bids.amount : 1 am getting below results Result: { "_id" : "93EDoQfeYEFk8pyzX", "name" : "bbb" } { "_id" :