0

I'd like to join two tables and write get url with joined table (make get, post, delete on joined table). I know how to do it with single table (e.g.):

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

So i found in Rethinkdb documentation useful command: https://www.rethinkdb.com/docs/table-joins/

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

Returns the following result:

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

}

How should I write my get code in nodejs? I don't know how can I name the merged table or how to call it.

1 Answers1

0

Following the documentation:

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

I'd assume the table will still be named "employees"

DGK
  • 2,947
  • 5
  • 32
  • 47