Sorting records in a way so that only records which matches an id comes first?
问题 I have a query which return me the records or messages for a certain scenario: const [messages, messageCount] = await Promise.all([ MessageModel.find(params).select(filterObject).limit(ctx.query.limit).skip(ctx.paginate.skip) .sort('-sex -age') .lean(), MessageModel.countDocuments(params), ]); Is there any way to get the records first which matches an object id, and then rest of the records? Result { _id:abc0aa8573bfa917b152cdbc isPrivate:false message:"My name is stark" gender:"unisex" age: