如何迭代和过滤rethinkdb db提交?

时间:2016-12-06 23:58:31

标签: rethinkdb rethinkdb-javascript

我在我的数据库中有这个:

{
    "id": "d40110a1-c0ca-47e0-95ca-086e905dd53c",
    "somefiled": [
        {
            "city_name": "Aadorf",
            "de": "Aadorf",
            "en": "Aadorf",
            "fr": "Aadorf",
            "it": "Aadorf",
            "kanton_de": "Thurgau",
            "kanton_en": "Thurgovie",
            "kanton_fr": "Thurgau",
            "kanton_it": "Turgovia"
        },
        {
            "city_name": "Aarau",
            "de": "Aarau",
            "en": "Aarau",
            "fr": "Aarau",
            "it": "Aarau",
            "kanton_de": "Aargau",
            "kanton_en": "Argovie",
            "kanton_fr": "Aargau",
            "kanton_it": "Argovia"
        }//many more records here]
}

如何在somefiled中提取kanton_en的值为Argovie的所有数组元素?

这样的事情:

r.db("test").table("table").getField("somefiled").filter(function(row){

  return row("kanton_en").eq("Argovie")
})

但那当然没有任何回报。

1 个答案:

答案 0 :(得分:1)

解决:

array_chunk($files, 6)