db.restaurants.find({ $or: [ { $and: [ {cuisine: {$ne: 'American'}}, {cuisine: {$ne: 'Chinese'}} ] }]}, {name: "/^Wil/"} ] }, {name: 1, cuisine:1})
错误:
uncaught exception: SyntaxError: missing ) after argument list :
这种长查询有很多括号,我无法正确匹配它们。有没有一个特定的工具/IDE可以用来编写这些查询?
试试这个:
db.restaurants.find({ $or: [ { $and: [ { cuisine: { $ne: "American" } }, { cuisine: { $ne: "Chinese" } } ] }, { name: /^Wil/ } ] }, { name: 1, cuisine: 1 })
MongoPlayground
MongoPlayground . 对于更复杂的查询,我通常使用 Robo3t / Studio3t .
Robo3t / Studio3t