Dev*_*rim 27 querying mongodb odm
如何查询其中有苹果的冰沙?(下面是一个包含3个文件的集合)
_id => 1
name => 'best smoothie'
ingredients => Array
(
[0] => apple
[1] => raspberry
[2] => orange
[3] => banana
)
_id => 2
name => 'summer smoothie'
ingredients => Array
(
[0] => lemon
[1] => mint
)
_id => 3
name => 'yogurt smoothie'
ingredients => Array
(
[0] => apple
[1] => blueberry
)
Run Code Online (Sandbox Code Playgroud)
Ste*_*iec 47
如果您只是运行以下查询,MongoDB足够聪明,可以弄清楚您要尝试做什么.
{ ingredients: "apple" }
Run Code Online (Sandbox Code Playgroud)
Mongo会看到成分是一个列表,只返回包含"apple"的文档,其中包含该列表中的某些内容.
| 归档时间: |
|
| 查看次数: |
16458 次 |
| 最近记录: |