1 回答

TA貢獻1810條經(jīng)驗 獲得超4個贊
$or 我猜你想像 sql 那樣 使用 查詢
這是java的演示
BasicDBObject query = new BasicDBObject();
BasicDBObject condition1 = new BasicDBObject("fieldA",new BasicDBObject("$gt","2018-06-02 12:20:00").append("$lt","2019-06-02 12:20:00"));
BasicDBObject condition2 = new BasicDBObject("fieldB",new BasicDBObject("$gt","2018-06-02 12:20:00").append("$lt","2019-06-02 12:20:00"));
BasicDBList condList = new BasicDBList();
condList.add(condition1);
condList.add(condition2);
query.put("$or" ,condList);
collection.find(query);
均值 $gt大于和 $lt 均值小于。
添加回答
舉報