我想加入两个表并用连接表写get url(在连接表上make get,post,delete)。 我知道如何使用单个表格(例如):
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中编写获取代码?我不知道如何命名合并表或如何调用它。
答案 0 :(得分:0)
遵循文件:
If you use the zip command after join,
the document from the right table will be merged into the left one.
我认为该表仍将被命名为"员工"