Open sondavide opened 6 months ago
This is not possible unfortunately. It requires complex Mongo queries in the backend.
Ok, the cleanest workaround is to add two parameter in the controller:
@GetMapping("/search")
public ResponseEntity<Page<UserDto>> search(@Filter(entityClass = User.class) Query query, Pageable pag, @RequestParam(required = false)List<String> role){
if(role!=null && role.size()>0)
query.addCriteria(Criteria.where("role.$id").in(role.stream().map(it-> new ObjectId(it)).toList()));
return ResponseEntity.ok(userService.search(query, pag).map(it -> new UserDto(it)));
}
this kind of query works for example:
{ "role.$id" : { "$in" : [{ "$oid" : "6411a9fe93dc05fff53666c4"}]}}
Hi, I'm using this version:
there's a way to create a filter for a DBRef property?
For example, if I have this class:
class User{ String name; String surname; ... @DBRef private List role;
}
how can I do for example a query by role.$id = "642ebb0e91ac8f778f5654b7" ?