Eldamir
Eldamir

Reputation: 10062

making joins in rethinkdb

I am trying to make a join between two tables. The command I'm running is:

r.table("userclientmap").eq_join("user_id", r.table("users"))

My 'user' table looks like this:

[
    {
        "email":  "[email protected]"
        "password":  "$2a$10$nO4/KHYkKRcx3D8GYwMCVu.gtsWd1SWzWz27N.TdxqdD9bf.LBXI6"
    }
]

My 'userclientmap' table looks like this:

[
    {
        "client_id":  "3c0e6447-ab2f-401e-a09d-d84c32406fe2" ,
        "id":  "d6356002-9e51-4f82-afb7-49799f7b5ded" ,
        "user_id":  "[email protected]"
    }
]

I am getting the following error when running my query from the administration console:

A query could not be executed.

r.table("userclientmap").eq_join("user_id", r.table("users"))

Error:

TypeError: Object function () {
    var args;
    args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
    if (args.length !== fun.length) {
      throw new err.RqlDriverError("Expected " + fun.length + " argument(s) but found " + args.length + ".");
    }
    return fun.apply(this, args);
  } has no method 'eq_join'

I don't really know where to go from here. My query looks exactly like the ones from the documentation on http://rethinkdb.com/docs/table-joins/

I'm running rethinkdb version 1.8.1-0ubuntu1~raring (GCC 4.7.3)

Upvotes: 0

Views: 934

Answers (1)

Michael Glukhovsky
Michael Glukhovsky

Reputation: 1018

The Data Explorer in the admin UI uses JavaScript, whereas the documentation for joins (http://rethinkdb.com/docs/table-joins/) uses Python examples. eqJoin is the JavaScript driver's equivalent of eq_join in Python.

You should use:

r.table('userclientmap').eqJoin('user_id', r.table('users'))

(see http://www.rethinkdb.com/api/#js:joins-eqJoin).

Upvotes: 7

Related Questions