MongoDB-LIKE 사용

MongoDB에서 LIKE를 사용하는 방법이다

String name = "aaa";
Query query = new Query();
query.addCriteria(Criteria.where("name").regex(name));
-- name like '%aa%'
db.getCollection('collection').find(name:/aa/)

-- name like 'aa%'
db.getCollection('collection').find(name:/^aa/)

-- name like '%aa'
db.getCollection('collection').find(name:/aa$/)