假设:
专辑文档:
{
"photoName": "photoName1.img";
"photoId": "photo1Id";
"otherData": "Some other data"
}
照片文件:
{
"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"
}]
}
其中Photo Document的密钥与photoId相同。
我想创建一个具有此输出的SELECT语句:
gcc
这是可能的还是我必须创建多个选择?
答案 0 :(得分:2)
使用NEST clause在结果文档中输出照片数组。
示例:(我使用类型来过滤您的文档类型,但它可能不是您的情况)
SELECT * FROM bucket albums
NEST bucket photos ON KEYS albums.photos
WHERE albums.type='Album'