我在 rethinkdb 数据库中的 json 如下(我给出了 4 个文档作为示例):
{
"label": {
"id": 59,
"country": "Germany",
"formats": {
"format": {
"text": "",
"name": "CD",
"qty": 1,
"descriptions": {
"description": [
"Album",
"Limited Edition"
]
}
}
}
}
}
{
"label": {
"id": 60,
"country": "US",
"formats": {
"format": {
"text": "",
"name": "CD",
"qty": 1,
"descriptions": {
"description": "Album"
}
}
}
}
}
{
"label": {
"formats": {
"format": {
"text": "",
"name": "Vinyl",
"qty": 1,
"descriptions": {
"description": [
"12\"",
"33 ⅓ RPM"
]
}
}
},
"country": "US",
"id": 42
}
}
{
"label": {
"formats": {
"format": {
"text": "",
"name": "Vinyl",
"qty": 1,
"descriptions": {
"description": "12\""
}
}
},
"country": "US",
"id": 10
}
}
我想过滤那些专辑标签。描述标签包含此信息。然而,这个元素有时是一个数组,有时是一个字符串。无论数据类型如何,我都需要那些包含值“专辑”的标签。到目前为止,我只能得到“描述”是字符串的那些值。这是我到目前为止可以使用的代码:
r.table("labels")('label').filter(r.row("formats")("format")("descriptions")("description").eq("Album"))('id')
有没有办法获得即使是专辑也存在于数组中的那些 id 值?提前致谢