My json in the rethinkdb database is as follows (I have given 4 docs as an example) :
{
"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
}
}
I would like to filter those labels which are albums. The description tag contains this information. However, this element is sometimes an array, sometimes a string. I need those labels which contains the value "Album" regardless the data type. So far I can only get those values where "description" is a string. This is the code I can use so far:
r.table("labels")('label').filter(r.row("formats")("format")("descriptions")("description").eq("Album"))('id')
Is there a way to get even those id values where Album exists within an array as well? Thanks in advance