gpt4 book ai didi

沙发底座 N1QL : How to aggregate and join from the same bucket with an array of keys

转载 作者:行者123 更新时间:2023-12-04 13:23:49 24 4
gpt4 key购买 nike

假设:

专辑文件:

{ 
"albumName": "my album",
"photos": [photo1Id, photo2Id, photo3Id]
}

照片文档:

{
"photoName": "photoName1.img";
"photoId": "photo1Id";
"otherData": "Some other data"
}

其中Photo Document的key与photoId相同。

我想做一个将有这个输出的 SELECT 语句:

{ 
"albumName": "my album",
"photos": [{
"photoName": "photoName1.img";
"photoId": "photo1Id";
"otherData": "Some other data"
},{
"photoName": "photoName2.img";
"photoId": "photo2Id";
"otherData": "Some other data"
},{
"photoName": "photoName3.img";
"photoId": "photo3Id";
"otherData": "Some other data"
}]
}

这可能吗,还是我必须创建多个选择?

最佳答案

使用 NEST clause在结果文档中输出照片数组。

示例:(我使用 type 来过滤您的文档类型,但它可能不是您的情况)

SELECT * FROM bucket albums
NEST bucket photos ON KEYS albums.photos
WHERE albums.type='Album'

关于沙发底座 N1QL : How to aggregate and join from the same bucket with an array of keys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43900446/

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