mongo 多条件or

or语句

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

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

 

等于java mongotemplatejava

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);
相关文章
相关标签/搜索