$and

    在集合 foo.bar 插入2条记录:

    1. > db.foo.bar.insert( { "id": 100, "time": { "$date": "2012-10-01" }, "income": 10000, "expenses": 500 } )
    2. > db.foo.bar.insert( { "id": 200, "time": { "$date": "2012-10-01" }, "income": 9000, "expenses": 1000 } )
    • 查询“time”字段值大于或等于2010年1月1日,并且“income”字段值等于10000的记录
    • 查询字段“income”值大于0,并且小于10000的记录:

    或者

    1. > db.foo.bar.find( { "income": { "$gt": 0, "$lt": 10000 } } )
    2. {
    3. "_id": {
    4. "$oid": "5821afcd2b4c38286d000004"
    5. },
    6. "time": {
    7. "$date": "2013-05-01"
    8. },
    9. "income": 9000,
    10. "expenses": 1000
    11. }