我想在MongoDB上实现以下SQL查询:
SQL:
&&
MongoDB的:
SELECT * FROM marvel WHERE likes > 10 AND (by = "professorX" OR title = "X-Men");
有没有办法在MongoDB中优化相同的查询?
答案 0 :(得分:0)
db.marvel.find({
$and:
[
{likes: {$gt: 10},
{ $or : [ { by : "professorX"}, { title : "X-title" } ] }
]
})