Mongoose: how to use index in aggregate?
问题 How can I use indexes in aggregate? I saw the document https://docs.mongodb.com/manual/core/aggregation-pipeline/#pipeline-operators-and-indexes The $match and $sort pipeline operators can take advantage of an index when they occur at the beginning of the pipeline. Is there any way of using index not the beginning situation? like $sort , $match or $group Please help me 回答1: An index works by keeping a record of certain pieces of data that point to a given record in your collection. Think of