【发布时间】:2019-03-22 21:05:28
【问题描述】:
我在 Couchbase 存储桶中有如下所示的 json 文档
{
"id":"10"
"threadId": "thread1",
"createdDate": 1553285245575,
}
{
"id":"11"
"threadId": "thread1",
"createdDate": 1553285245776,
}
{
"id":"12"
"threadId": "thread2",
"createdDate": 1553285245575,
}
我正在尝试创建一个查询,该查询基于按 threadId 的组和按 createdDate 的最新文档获取文档。
我写了一个这样的 n1ql 查询,但它只返回这样的 documentId。
SELECT max([mes.createdDate,meta(mes).id])
from `messages` as mes
group by mes.threadId
result:
[
{
"$1": [
1553285245776,
"11"
]
},
{
"$1": [
1553285245737,
"12"
]
}
]
但我想要这样的结果
[{
"id":"10"
"threadId": "thread1",
"createdDate": 1553285245575,
}
{
"id":"11"
"threadId": "thread1",
"createdDate": 1553285245776,
}]
任何帮助将不胜感激
【问题讨论】:
标签: couchbase n1ql couchbase-view spring-data-couchbase