当前位置:首页 > 数据库 > 正文

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

2024-03-31 数据库

需要对 id 进行转换

const mongoose = require(‘mongoose‘) var ObjectId = mongoose.Types.ObjectId;   await Users.aggregate([     {        $match : { "_id":new ObjectId("5asdasdasc66b6aae717b")}      }  ])

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/SQL/13182.html