Hey, I have the following schema:
const Objects = new mongoose.Schema({
name: {
type: String,
required: true,
},
utility: {
type: String,
required: true,
},
createdAt: {
type: Date,
default: Date.now,
}
})
What I want to do is to pick all data, for example, and then, make a rank of the objects.
For example, lets suppose the collection has 5 documents with the name “Pencil”, and then 8 documents with the name “Eraser”.
So the rank would be, of course:
Eraser - 8
Pencil - 5
But I don’t know the names of the objects to apply some $match or something, I need to get it from the data…