首页 文章

RethinkDB简单地从嵌套数组中提取

提问于
浏览
1

我是RethinkDB的新手,已经在这里和其他地方寻找答案 . 我发现有几件事情很接近,但似乎仍然无法弄清楚它应该是什么样的简单 . 我有一个问题:

r.db('common').table("counters").filter({org: 'myorg'}).pluck('counters').run()

这给出了以下结果:

{
  "counters": [
    {
      "aid": 0 ,
      "pid": 1000 ,
      "rid": 0
    }
  ]
}

我想要的是 pluck 或以某种方式得到一个特定的计数器(例如pid) . 我试过 counter[0].pidcounters.pid 和其他几个,但是't quite seem to find the magic bullet. From what I did find, I suspect this may involve a function, but am not sure where it should go. Any help is appreciated and if you dup this, please make sure it'是一个完全重复,而不是接近 . 谢谢!

1 回答

  • 1

    好的,必须将数组更改为对象:

    {
      "counters": {
        "aid": 0 ,
        "pid": 1000 ,
        "rid": 0
      }
    }
    

    ...然后使用 get() ,这有效 r.db('common').table("counters").get('12345-1234-54321-6666-f0dac0b6b68e')('counters')('pid')

相关问题