的内部阵列我有一个文件是这样的:MongoDB的筛选对象
-document: users-
{
"name": "x", password: "x" recipes:
[{title: eggs, dificult: 1},{title: "pizza" dificult: 2}],
name: "y", password: "y" recipes: [{title: "oil", dificult: 2},{title: "eggandpotatoes" dificult: 2}]
}
我想所有的食谱由标题和难治过滤
我已经尝试了一些类似这样的
db.users.find({$and: [{"recipes.title": /.*egg.*/},{"recipes.dificult": 2}]},
{"recipes.title": 1,"recipes.dificult": 1}).toArray();
这应该返回
{title: "eggandpotatoes" dificult: 2}
但返回
{title: eggs, dificult: 1}
{title: "eggandpotatoes" dificult: 2}
我愿再次过滤器的工作原理,限制与开始结果:2和端部:5 从2结果返回提前在未来5
感谢。