我正在尝试根据哈希中的一些预先计算的值更新 RethinkDB 中的多个文档。IE
stats
给定一个带有主键的表,slug
其中的数据如下
[{slug: 'foo', stats: {}}, {slug:'bar', stats:{}}]
并给出一个哈希值,如
updated_stats = {
'foo' => {a: 1, b: 2},
'bar' => {a: 3, b: 4}
}
我可以做这个
updated_stats.each{|k,v|
r.table('stats').get(k).update{|s|
{ :stats => v }
}
}
那么,为什么我不能执行以下操作?
r.table('stats').get_all(*updated_stats.keys).update{|s|
{ :stats => updated_stats[s["slug"]] }
}
rql 将 nil 显示为 updated_stats[s["slug"]] 的值。非常感谢您对此的任何帮助。谢谢。