我有2个RethinkDB表:
Left:
{
id: String,
title: String,
key: String // for mapping with table Right
}
Right:
{
id: String
title: String
description: String
}
Run Code Online (Sandbox Code Playgroud)
RethinkDB有eqJoin()和zip()方法,它们帮助我们将表的所有字段克隆到表左边:
r.db("myDB").table("Left")
.eqJoin("key", r.db("myDB").table("Right"))
.zip()
Run Code Online (Sandbox Code Playgroud)
结果将如下所示:
[{
id: "the-id",
key: "Right-object-id",
title: "Title of Right Object",
description: "Description of Right Object"
// => title of Left Object was deleted
}]
Run Code Online (Sandbox Code Playgroud)
现在的问题是: 如何模拟像查询)填入(的猫鼬?
我希望结果看起来像这样:
[{
id: "the-id",
key: {
id: "Right-object-id"
title: "Title of Right Object"
description: "Description of Right Object"
} …Run Code Online (Sandbox Code Playgroud) rethinkdb ×1