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);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM