我在我的OrientDB数据库中的文档(1.0.1版本),在很大程度上与这样的结构:查询嵌入列表OrientDB
{
"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"
}
]
}
我如何可以查询整个列表,例如。如果我想查找包含类型为“忽略”的测试用例的所有文档?
我已经尝试下面的查询
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')
我遇到了同样的问题。您可以在问题中发布更新并接受它。那正是我正在寻找的。 – 2014-11-05 15:08:04
@DavidLaberge:谢谢你的建议。这个问题太古老了,我坦率地没有完全记住它的背景,所以我会对这个操作感到有些不安。至少根据OrientDB的文档,我还有一种感觉,即我的初始方法应该起作用,所以鼓励人们像上面那样重新调整数据库会是一种错误。 – Henrik 2014-11-05 18:12:25