mongo 多条件or

or语句

1 > select * from xx where a=1 or b=2

2 > db.XXX.find({"$or":[{"a":1}, {"b":2}]}); 

 

等于java mongotemplate

1 Query query = new Query();
2 
3 Criteria criteria0 = new Criteria();
4 Criteria criteria1 = Criteria.where("accid").is(queryKey);
5 Criteria criteria2 = Criteria.where("phone").is(queryKey);
6 criteria0.orOperator(criteria1, criteria2);
7 
8 query.addCriteria(criteria0);
9 List<Player> playerList = mongoDao.findAll(query, MongoKey.PLAYER, Player.class);

 

posted @ 2019-04-22 10:24  Other+  阅读(2724)  评论(0)    收藏  举报