如何对使用文档 ID 检索的文档的内部数组进行排序
How to sort inner array of document which is retrieved by using document ID
SELECT * from bucket b WHERE meta().id = 'PROFILE_LIST'
上面的查询给出了下面的结果,但另外我需要内部数组 matchingProfile_ 应该按照 createdDate 的排序顺序出现。可能吗?如果是,我必须对此查询进行哪些更改才能实现相同的目标?
[
{
"matchingProfile_": [
{
"createdDate": "2020-09-26T02:30:00",
"contactDetails_": {
"address_": {
"addressLine1_": "",
"addressLine2_": "",
"city_": ""
}
},
{
"createdDate": "2020-09-27T02:30:00",
"contactDetails_": {
"address_": {
"addressLine1_": "",
"addressLine2_": "",
"city_": ""
}
}
]
}
]
使用子查询表达式保留整个文档结构并按所需方式对数组进行排序(甚至使用完整的 SQL 功能)
SELECT b.*,
(SELECT RAW mp
FROM b.matchingProfile_ AS mp
ORDER BY mp.createdDate) AS matchingProfile_
FROM bucket AS b USE KEYS 'PROFILE_LIST';
SELECT * from bucket b WHERE meta().id = 'PROFILE_LIST'
上面的查询给出了下面的结果,但另外我需要内部数组 matchingProfile_ 应该按照 createdDate 的排序顺序出现。可能吗?如果是,我必须对此查询进行哪些更改才能实现相同的目标?
[
{
"matchingProfile_": [
{
"createdDate": "2020-09-26T02:30:00",
"contactDetails_": {
"address_": {
"addressLine1_": "",
"addressLine2_": "",
"city_": ""
}
},
{
"createdDate": "2020-09-27T02:30:00",
"contactDetails_": {
"address_": {
"addressLine1_": "",
"addressLine2_": "",
"city_": ""
}
}
]
}
]
使用子查询表达式保留整个文档结构并按所需方式对数组进行排序(甚至使用完整的 SQL 功能)
SELECT b.*,
(SELECT RAW mp
FROM b.matchingProfile_ AS mp
ORDER BY mp.createdDate) AS matchingProfile_
FROM bucket AS b USE KEYS 'PROFILE_LIST';