So, I have one @Document
class which has a embedded pojo field which I want it to be unique for the document based on a key
in the pojo class. I tried using @CompoundIndex
& @Indexed
to mark it as unique but it doesn't seem to work.
@Document
public class Project {
private String id;
private String name;
private List<Details> details = new ArrayList<>();
}
public class Details{
private String key;
private String description;
}
What I want to achieve is that a project
document should have unique details
field in it with it's key
being unique. But when I have the
@CompoundIndexes({ @CompoundIndex(name = "details_key", def = "{'details.key':1}", unique = true) })
on the Project
class it doesn't work. Which I thought it should. Or am I wrong somewhere with my understanding. As I am new to this.