MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Crea query dinamiche con Spring Data MongoDB Criteria

Non funziona per te?

Criteria criteria = Criteria.where("contentType").is("application/vnd.sometype");

List<Criteria> docCriterias = new ArrayList<Criteria>(docs.size());

for (Document doc: docs) {
    docCriterias.add(Criteria.where("metadata.name").is(doc.getName())
                               .and("metadata.version").is(doc.getVersion()));
}

criteria = criteria.orOperator(docCriterias.toArray(new Criteria[docs.size()]));

?