0

我想加入两个表并用加入的表编写获取 url(在加入的表上进行获取、发布、删除)。我知道如何使用单表(例如)来做到这一点:

 app.get('/employees', (req, res) => {
   r.table('employees').run(connection).then((cursor) => {
   // console.log(cursor)
   cursor.toArray().then((employees) => res.json(employees))
   })
 })

所以我在 Rethinkdb 文档中发现了有用的命令: https ://www.rethinkdb.com/docs/table-joins/

r.table("employees").eq_join("company_id", r.table("companies")).zip().run()

返回以下结果:

{
"id": "064058b6-cea9-4117-b92d-c911027a725a",
"name": "Jean-Luc Picard",
"company_id": "064058b6-cea9-4117-b92d-c911027a725a",
"rank": "captain",
"company": "Starfleet",
"type": "paramilitary"

}

我应该如何在 nodejs 中编写我的获取代码?我不知道如何命名合并表或如何调用它。

4

1 回答 1

0

遵循文档:

If you use the zip command after join, 
the document from the right table will be merged into the left one.

我假设该表仍将被命名为“员工”

于 2017-04-24T14:53:48.520 回答