【发布时间】:2015-02-05 12:19:46
【问题描述】:
我的 OrientDB 数据库(版本 1.0.1)中有一个文档,其结构大致如下:
{
"timestamp": "...",
"duration": 665,
"testcases": [
{
"testName": "test01",
"type": "ignore",
"filename": "tests/test1.js"
},
{
"iterations": 1,
"runningTime": 45,
"testName": "test02",
"type": "pass",
"filename": "tests/test1.js"
},
...
{
"testName": "test05",
"type": "ignore",
"filename": "tests/test1.js"
}
]
}
如何查询整个列表,例如。如果我想查找所有包含类型为“ignore”的测试用例的文档?
我尝试了以下查询
select from testresult where testcases['type'] = 'ignore'
但这会导致NumberFormatException。
select from testresult where testcases[0]['type'] = 'ignore'
有效,但显然只查看每个文档的第一个列表元素。
select from testresult where testcases contains(type = 'ignore')
不提供任何结果,但查询被接受为有效。
更新: 如果测试用例存储为单独的文档而不是嵌入列表,则以下查询按预期工作。
select from testresult where testcases contains (type = 'ignore')
【问题讨论】:
-
我遇到了和你一样的问题。您可以在问题中发布您的更新并接受它。这就是我想要的。
-
@DavidLaberge :感谢您的建议。这个问题太老了,坦率地说,我不完全记得它的上下文,所以我会对那个操作感到有点不安。我也有一种感觉,我最初的方法应该可行,至少根据 OrientDB 的文档,所以鼓励人们像上面那样重组他们的数据库是错误的。