Nosql Cosmos数据库查询,不知道对象的键
单个文档示例:Nosql Cosmos数据库查询,不知道对象的键,nosql,azure-cosmosdb,Nosql,Azure Cosmosdb,单个文档示例: { "id" : "xxxxxx", "properties": { "a_prop": { type: "names", value: "John", }, "b_prop": { type: "score", v
{
"id" : "xxxxxx",
"properties": {
"a_prop": {
type: "names",
value: "John",
},
"b_prop": {
type: "score",
value: 5.5,
},
"c_prop": {
type: "names",
value: "Steve",
}
}
}
问题-如何获取至少有一个属性类型为“name”的文档?
困难在于,我之前无法知道属性“a_prop”是一种“名称”类型。当您的模型包含具有未知、任意键的对象集合时,进行查询是毫无乐趣的。考虑将模型更改为已知密钥并将未知值存储为属性值。例如,将
属性
更改为项目数组:
{
id: "xxxxxx",
properties: [
{
name: "a_prop",
type: "names",
value: "John",
},
{
name: "b_prop",
type: "score",
value: 5.5,
},
{
name: "c_prop",
type: "names",
value: "Steve",
}
]
}
现在,对于属性类型为“名称”的项:
另请参见讨论。当您的模型包含具有未知任意键的对象集合时,进行查询是没有意思的。考虑将模型更改为已知密钥并将未知值存储为属性值。例如,将
属性
更改为项目数组:
{
id: "xxxxxx",
properties: [
{
name: "a_prop",
type: "names",
value: "John",
},
{
name: "b_prop",
type: "score",
value: 5.5,
},
{
name: "c_prop",
type: "names",
value: "Steve",
}
]
}
现在,对于属性类型为“名称”的项:
有关详细信息,请参见讨论