我有以下数据结构:
墙
{
slug: "wall-slug",
nodes: {
"node1": "id-from-nodes-table-1",
"node2": "id-from-nodes-table-2"
}
}
节点
{
id: "id-from-nodes-table-1",
something: "something"
}
尝试以这种方式将节点表中的文档合并到墙表中节点对象中的确定节点:
r.db("test").table("walls").getAll("wall-slug", {index: "slug"}).map(function(row) {
return row.merge({nodes: row("nodes").map(function(node) {
return r.db("test").table("nodes").get(node);
})});
})
它应该看起来像这样:
{
slug: "wall-slug",
nodes: {
"node1": {object from nodes table got by value from this property},
"node2": {object from nodes table got by value from this property}
}
}
但是我收到“无法将 OBJECT 转换为 SEQUENCE”消息 - 找不到迭代节点对象属性并用另一个表中的对象替换它的属性值的方法 - 有吗?