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);
相關文章
相關標籤/搜索