[英]How do I get the value property in this CosmosDB QUery?
I am trying to get deeper into an object but for some reason it does not work in my Cosmos query, the query is quite simple as follows.我试图更深入地了解一个对象,但由于某种原因它在我的 Cosmos 查询中不起作用,查询非常简单,如下所示。
SELECT c.id,
c.ItemNo,
bv.variantId AS variantNo,
bv.variantDescription AS title,
c.BasicData.presentation.articleLongDescription[0] AS Description,
c.BasicData.presentation.articleCompositionList.origin,
bv.size.sizeName,
c.BasicData.asset.assets[0].locations[1].path
FROM c
JOIN bv IN c.BasicData.base.sales.variants
WHERE c.brand = 'XXX'
AND c.Consumer = 'XXX'
AND bv.variantId = 'XXX'
AND c.Season = 'XXX'
The result is rather straight forward too as follows结果也相当直接,如下
[
{
"id": "9c9c5b56-999f-4f98-8c52-902f43dd4cfe",
"ItemNo": "0562168014",
"variantNo": "0562168014003",
"title": "Trousers Grey, 36",
"Description": {
"locale": "en-GB",
"value": "jongel fibbel"
},
"origin": "{\"\":{\"materials\":{\"002elastane\":\"30.0\",\"002polyester\":\"70.0\"}}}",
"path": "https://public.assets.XXX.com/assets/002/b0/1b/b01b4fa77023f48ca3c6ff8777cc27276f478f1e.jpg"
}
]
My problem is I want to return the "value" property "jongel fibbel" instead of the entire description object我的问题是我想返回“值”属性“jongel fibbel”而不是整个描述对象
I tried changing我试着改变
c.BasicData.presentation.articleLongDescription[0] AS Description,
To到
c.BasicData.presentation.articleLongDescription[0].value AS Description,
But that gives me a syntax error at value但这给了我一个语法错误的价值
How can I return the value properly in the above query?如何在上述查询中正确返回值?
EDIT -------编辑 - - - -
aricleLongDescription is an array as follows
"articleLongDescription": [
{
"locale": "en-GB",
"value": "jongel fibbel"
}
],
SO I also tried JOIN as follows所以我也试过 JOIN 如下
SELECT c.id,
c.ItemNo,
bv.variantId AS variantNo,
bv.variantDescription AS title,
ba.value AS Description,
c.BasicData.presentation.articleCompositionList.origin,
bv.size.sizeName,
c.BasicData.asset.assets[0].locations[1].path
FROM c
JOIN bv IN c.BasicData.base.sales.variants
JOIN ba IN c.BasicData.presentation.articleLongDescription
WHERE c.brand = 'XXX'
AND c.Consumer = 'XXX'
AND bv.variantId = 'XXX'
AND c.Season = 'XXXX'
But it also fails with syntax error at value但它也因语法错误而失败
EDIT ---编辑 - -
Also tried a subquery as follows还尝试了如下子查询
SELECT c.id,
c.ItemNo,
bv.variantId AS variantNo,
bv.variantDescription AS title,
--c.BasicData.presentation.articleLongDescription[0] AS Description,
-- ARRAY(SELECT serving.description FROM serving IN food.servings) AS servings
ARRAY(SELECT jongel.value FROM jongel IN c.BasicData.presentation.articleLongDescription) AS Description
c.BasicData.presentation.articleCompositionList.origin,
bv.size.sizeName,
c.BasicData.asset.assets[0].locations[1].path
FROM c
JOIN bv IN c.BasicData.base.sales.variants
JOIN ba IN c.BasicData.presentation.articleLongDescription
WHERE c.brand = 'XXX'
AND c.Consumer = 'XXX'
AND bv.variantId = 'XXX'
AND c.Season = 'XXX'
But it also fails with syntax error at value, I am wondering is "value" a protected keyword or something in CosmosDB?但它也因 value 的语法错误而失败,我想知道“value”是受保护的关键字还是 CosmosDB 中的某个东西?
As it turns out value is a reserved keyword in CosmosDB so the syntax to get around that is as follows事实证明 value 是 CosmosDB 中的保留关键字,因此绕过它的语法如下
c.BasicData.presentation.articleLongDescription[0]["value"] AS Description,
Note there is no .(dot) just brackets and doublequotes注意没有 .(dot) 只是括号和双引号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.