sql >> Base de Datos >  >> NoSQL >> MongoDB

Mongodb y submatriz de clasificación

Sorprendentemente, sí, mongodb puede hacer esto:

// 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 });