作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 Mongoid。我有一个如下所示的文档:
Pet:
foo: {bar: 1, foobar: 2}
another_attr: 1
在这种情况下,最好使用 Mongoid,我将如何查询 bar 值大于 0 且 another_attr 等于 1 的所有宠物?
最佳答案
在 mongo shell 中:
db.pets.find({"foo.bar":{$gt:0}, another_attr:1});
在 mongoid 中:
Pet.where(:'foo.bar'.gt => 0, :another_attr => 1)
关于mongodb - 如何对 MongoDB 文档中的散列执行此查询(使用 Mongoid),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12372688/
我是一名优秀的程序员,十分优秀!