我在 rethinkDB 中有一张这样的表。
[{
"Id": [
12,
13
],
"group": "79",
"go_Id": []
}, {
"Id": [
12,
12,
12,
14
14
],
"group": "91",
"go_Id": [
16,
16,
16,
19,
19,
20
]
}, {
"Id": [
12,
12,
13,
13,
11
],
"group": "second",
"go_Id": [
16,
17,
17,
16,
17,
17
]
}]
我希望 Id 和 go_Id 具有各个 id 的计数和它们的出现次数。因此,例如,所需的输出是
[{
"Id": [
12: 1
13: 1
],
"group": "79",
"go_Id": []
}, {
"Id": [
12: 3
14: 2
],
"group": "91",
"go_Id": [
16: 3,
19: 2,
20: 1
]
}, {
"Id": [
12: 2,
13: 2,
11: 1
],
"group": "second",
"go_Id": [
16: 2,
17: 4,
]
}]
我应该怎么做?
我尝试根据 id 分组,然后计数,但似乎不起作用。就像是r.table('dev').group(r.row('Id"))