我如何将这个基本句子翻译成 mongotemplate 或 mongorepository 我需要在集合用户中找到所有不同的名称
db.user.distinct('name');
@Document(collection = "user")
public class User {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
示例 Json
{
"_id" : "12358",
"name" : "HiMan",
"description" : "sales category",
}
{
"_id" : "791127",
"name" : "HiMan",
"description" : "",
}
{
"_id" : "123123",
"name" : "Rango",
"description" : "sales Rango",
}
我得到:[“Rango”,“HiMan”]