日期:2014-05-16 浏览次数:20418 次
在mongodb中有$or 操作符的,官网中给出的例子如下:
?
Simple:
db.foo.find( { $or : [ { a : 1 } , { b : 2 } ] } )
With another field
db.foo.find( { name : "bob" , $or : [ { a : 1 } , { b : 2 } ] } )
The?$or?operator retrieves matches for each or clause individually and eliminates duplicates when returning results. A number of?$or?optimizations are planned for 1.8. See?this thread?for details.
$or?cannot be nested. |