gpt4 book ai didi

java - 如何在 Spring 中为字段返回不同的值

转载 作者:可可西里 更新时间:2023-11-01 10:21:10 25 4
gpt4 key购买 nike

我可以使用 mongoDB 查询检索字段的不同值,

db.context.distinct("context_name")

结果 ["Restaurant", "School"]

我的 Mongo 集合名称是 Context 文档看起来像,

{
"_id" : ObjectId("57ca8a45cadee6167c4d92ba"),
"_class" : "com.something.webappmongo.domain.Context",
"context_name" : "Restaurant"
}

现在我想使用来自 Spring 框架 (Spring Boot 1.4.0) 的查询获得结果。我使用的是 Jhipster。

在repository接口(interface)和资源类中如何实现?

最佳答案

创建一个 Repository 方法“findDistinctBy[field]”

关于java - 如何在 Spring 中为字段返回不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39307755/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com