我的rethinkdb中有一堆文件看起来像这样。
[
{
"complete": false,
"blobs": [
{
"base64": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"fingerprint": "123",
"data": {
"meta1": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Serial Number": 123456,
"hash": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"meta2": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Info:": {
"length": 1024
},
"Validity": {
"begin": "20280801235959Z",
"end": "19960129000000Z"
},
"Version": 0,
"item count:": 0
}
},
{
"base64": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"fingerprint": "456",
"data": {
"meta1": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Serial Number": 123456,
"hash": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"meta2": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Info:": {
"length": 1024
},
"Validity": {
"begin": "20280801235959Z",
"end": "19960129000000Z"
},
"Version": 0,
"item count:": 0
}
},
{
"base64": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"fingerprint": "789",
"data": {
"meta1": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Serial Number": 123456,
"hash": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"meta2": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Info:": {
"length": 1024
},
"Validity": {
"begin": "20280801235959Z",
"end": "19960129000000Z"
},
"Version": 0,
"item count:": 0
}
},
{
"base64": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"fingerprint": "101112",
"data": {
"meta1": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Serial Number": 123456,
"hash": "MIICPDCCAaUCEHC65B0Q2Sk0tjjKe",
"meta2": {
"a": "abc",
"b": "bcd",
"c": "cdf"
},
"Info:": {
"length": 1024
},
"Validity": {
"begin": "20280801235959Z",
"end": "19960129000000Z"
},
"Version": 0,
"item count:": 0
}
}
],
"port": 443,
"items": [
{
"blobs": [
"123",
"457",
"789",
"10112"
]}
],
"secure": true,
"fast": true
}
]
每个文档都包含几个“blob”。我需要查询所有文档中的所有blob并返回与指纹匹配的“blob”。我正在努力弄清楚这应该是什么样的。
我尝试了此查询但返回了所有文档。
r.db('db').table('data').filter(r.row('blobs').contains(function(product) {
return product('fingerprint').eq('742c3192e607e424eb4549542be1bbc53e6174e2');
}))
答案 0 :(得分:0)
这样做你想要的吗?
table.concatMap(function(row) { return row('blobs'); }).filter(function(blob) {
return blob('fingerprint').eq('742c3192e607e424eb4549542be1bbc53e6174e2');
})