๋ฐ์ํ
Intro
์๋ ํ์ธ์. ์ด๋ฒ ์๊ฐ์๋ ์คํ๋ง๋ถํธ + ๋ชฝ๊ณ (mongo)์์ OR ์ฟผ๋ฆฌ query ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค.
How to do
Criteria API๋ฅผ ์ฌ์ฉํ์ฌ ์๋์ ๊ฐ์ด ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค.
Criteria criteria = new Criteria();
criteria.orOperator(Criteria.where("A").is(10),Criteria.where("B").is(20));
Query query = new Query(criteria);
mongoOps.find(query, <Yourclass>.class, "collectionName");
+) ์ฐธ๊ณ ๋ก Criteria ์ ๊ธฐ์ค๊ฐ์ด๋ผ๋ ์๋ฏธํ๋๋ค. find ๋ฉ์๋ ์์์ { age: { $gt: 18 } } ์ ๊ฐ์ ์กฐ๊ฑด๋ฌธ์ ์ ๋ ฅํ๋ ๋ถ๋ถ์ ๋ปํฉ๋๋ค.
db.users.find( // collecrtion
{ age: { $gt: 18 } }, // query criteria
{ name: 1, address: 1 } // projection
).limnit(5)
https://stackoverflow.com/questions/16478101/spring-data-mongo-use-or-in-query
๋ฐ์ํ