Mongodb - 解决 ( aggregate聚合管道 ) $match 根据 id 匹配 返回 [ ] 的问题

需要对 id 进行转换

const mongoose = require('mongoose')
var ObjectId = mongoose.Types.ObjectId;
 
await Users.aggregate([
    { 
      $match : { "_id":new ObjectId("5asdasdasc66b6aae717b")} 
    }
 ])
posted @ 2020-01-19 18:01  武卡卡  阅读(1673)  评论(0编辑  收藏  举报