{"id":3293,"date":"2016-03-07T03:39:03","date_gmt":"2016-03-07T03:39:03","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3293"},"modified":"2016-03-07T03:39:03","modified_gmt":"2016-03-07T03:39:03","slug":"fixing-expected-type-table-found-selection-rethinkdb","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-expected-type-table-found-selection-rethinkdb\/","title":{"rendered":"Fixing &#8220;Expected type TABLE but found SELECTION&#8221; in RethinkDB"},"content":{"rendered":"<p>If you write a query that tries to compare two datasets, you may get errors:<\/p>\n<pre lang=\"javascript\">\nr.db('test')\n .table('users')\n .get('first_name')\n .setIntersection(\n   r.db('test')\n    .table('users')\n    .filter(\n      (x) => x('user_name').match('9')\n    )\n    .get('first_name')\n )\n<\/pre>\n<p>Like so:<\/p>\n<pre>\ne: Expected type TABLE but found SELECTION:\n<\/pre>\n<p>Clearly this indicates that we&#8217;re trying to compare two different dataset types.<\/p>\n<p>The above query is attempting to filter one table by another. To do this correctly, try this:<\/p>\n<pre lang=\"javascript\">\nr.db('test')\n .table('users')\n .eqJoin(\n     'id',\n     r.table('users')\n   )\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you write a query that tries to compare two datasets, you may get errors: r.db(&#8216;test&#8217;) .table(&#8216;users&#8217;) .get(&#8216;first_name&#8217;) .setIntersection( r.db(&#8216;test&#8217;) .table(&#8216;users&#8217;) .filter( (x) => x(&#8216;user_name&#8217;).match(&#8216;9&#8217;) ) .get(&#8216;first_name&#8217;) ) Like so: e: Expected type TABLE but found SELECTION: Clearly this indicates that we&#8217;re trying to compare two different dataset types. The above query is attempting to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/fixing-expected-type-table-found-selection-rethinkdb\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fixing &#8220;Expected type TABLE but found SELECTION&#8221; in RethinkDB&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[302,462,466,523],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3293"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3293"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3293\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}