{"id":3444,"date":"2016-03-16T12:44:35","date_gmt":"2016-03-16T12:44:35","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3444"},"modified":"2016-03-16T12:44:35","modified_gmt":"2016-03-16T12:44:35","slug":"rethinkdb-right-join-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/rethinkdb-right-join-example\/","title":{"rendered":"RethinkDB: RIGHT JOIN Example"},"content":{"rendered":"<p>RethinkDB has a function called &#8220;outerJoin&#8221;, which actually does a left join. <\/p>\n<p>For example, this finds users and adds their audit trail history (if any):<\/p>\n<pre lang=\"javascript\">\nr.db('test')\n .table('user_actions')\n .outerJoin(r.table('users'),\n    (action, user) => \n      action('user_id').eq(user('id')))\n .zip()\n<\/pre>\n<p>If instead you want to start with audit history and add users (if they exist) you have to swap everything manually, since at this time there is no right join:<\/p>\n<pre lang=\"javascript\">\nr.db('test')\n .table('users')\n .outerJoin(r.table('user_actions'),\n    (user, action) => \n      action('user_id').eq(user('id')))\n .zip()\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>RethinkDB has a function called &#8220;outerJoin&#8221;, which actually does a left join. For example, this finds users and adds their audit trail history (if any): r.db(&#8216;test&#8217;) .table(&#8216;user_actions&#8217;) .outerJoin(r.table(&#8216;users&#8217;), (action, user) => action(&#8216;user_id&#8217;).eq(user(&#8216;id&#8217;))) .zip() If instead you want to start with audit history and add users (if they exist) you have to swap everything manually, since &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/rethinkdb-right-join-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;RethinkDB: RIGHT JOIN Example&#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":[160,462,466,523],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3444"}],"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=3444"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3444\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}