or语句

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

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

 

等于java mongotemplate

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
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);

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄