从 COSMOS db 查询访问选择性数组项
query for access selective array items from COSMOS db
我需要从 cosmos db 集合中的以下数组中获取一些选择性数组项。
“详情”:[
{
"name": "a",
"roll_no": 100,
"sub":"maths",
"class":"3"
},
{
"name": "b",
"roll_no":"512",
"sub":"eng",
"class":"5"
},
{
"name": "c",
"roll_no":"512",
"sub":"eng",
"class":"7"
}
and so on
期望的输出是:
“详情”:[
{
"name": "a",
"roll_no": 100,
},
{
"name": "b",
"roll_no":"512",
},
{
"name": "c",
"roll_no":"512",
}
and so on
如何在 cosmosb 数据库中编写相同的查询?
使用子查询和 ARRAY
函数将起作用:
SELECT c.id, ARRAY(SELECT d.name, d.roll_no FROM d in c.details) AS details
FROM c
我需要从 cosmos db 集合中的以下数组中获取一些选择性数组项。
“详情”:[ {
"name": "a",
"roll_no": 100,
"sub":"maths",
"class":"3"
},
{
"name": "b",
"roll_no":"512",
"sub":"eng",
"class":"5"
},
{
"name": "c",
"roll_no":"512",
"sub":"eng",
"class":"7"
}
and so on
期望的输出是:
“详情”:[ {
"name": "a",
"roll_no": 100,
},
{
"name": "b",
"roll_no":"512",
},
{
"name": "c",
"roll_no":"512",
}
and so on
如何在 cosmosb 数据库中编写相同的查询?
使用子查询和 ARRAY
函数将起作用:
SELECT c.id, ARRAY(SELECT d.name, d.roll_no FROM d in c.details) AS details
FROM c