这是数据库集合-作业:
{
"skillsRequired": ["html", "css", "javascript"],
"qualification": [ "BE", "B-Tech"],
"company" : "microsoft"
},
{
"skillsRequired": ["html", "ml", "ai", "python"],
"qualification": [ "BE", "B-Tech"],
"company" : "microsoft"
},
{
"skillsRequired": ["ml", "ai", "python"],
"qualification": [ "BE", "B-Tech"],
"company" : "microsoft"
}当参数为"skillsRequired“:"html","css"时,如何获得以下输出
[{
"skillsRequired": ["html", "css", "javascript"],
"qualification": [ "BE", "B-Tech"],
"company" : "microsoft"
},
{
"skillsRequired": ["html", "ml", "ai", "python"],
"qualification": [ "BE", "B-Tech"],
"company" : "microsoft"
}]简而言之,查询应该返回参数查询中的任何元素与文档匹配的所有记录/文档。
发布于 2020-04-12 09:44:25
const query = {};
if (skillsRequiredParam && skillsRequiredParam.length > 0)
query.skillsRequired = {$in: skillsRequiredParam}
}
const docs = await db.collection.find(query).exec();https://stackoverflow.com/questions/61169306
复制相似问题