MongoDB
 sql >> Datenbank >  >> NoSQL >> MongoDB

Mongodb und Sortier-Sub-Array

Erstaunlicherweise kann mongodb das:

// Sort ascending, by minimum percentage value in the docs' offers array.
db.collection.find({}).sort({ 'offers.percentage': 1 });

// Sort descending, by maximum percentage value in the docs' offers array.
db.collection.find({}).sort({ 'offers.percentage': -1 });