{"id":3278,"date":"2016-03-07T02:58:40","date_gmt":"2016-03-07T02:58:40","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3278"},"modified":"2016-03-07T02:58:40","modified_gmt":"2016-03-07T02:58:40","slug":"rethinkdb-column-alias-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/rethinkdb-column-alias-example\/","title":{"rendered":"RethinkDB: Column Alias Example"},"content":{"rendered":"<p>If you want to rename columns in a RethinkDB query, you can do it with map:<\/p>\n<pre lang=\"javascript\">\nr.db('test')\n .table('users')\n  .map({ login_name: r.row('user_name' ) })\n<\/pre>\n<p>This will rename &#8220;user_name&#8221; to &#8220;login_name&#8221;. Note that the output of this is only the columns listed specifically in map &#8211; all others would be removed.<\/p>\n<p>If you do this after a &#8220;group&#8221;, but you&#8217;ll need to do an ungroup to get the result correct:<\/p>\n<pre lang=\"javascript\">\nr.db('test')\n .table('users')\n .group('first_name')\n .count()\n .ungroup()\n .map(\n   { \n    first_name: r.row('group'),\n    val: r.row('reduction') \n  })\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you want to rename columns in a RethinkDB query, you can do it with map: r.db(&#8216;test&#8217;) .table(&#8216;users&#8217;) .map({ login_name: r.row(&#8216;user_name&#8217; ) }) This will rename &#8220;user_name&#8221; to &#8220;login_name&#8221;. Note that the output of this is only the columns listed specifically in map &#8211; all others would be removed. If you do this after a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/rethinkdb-column-alias-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;RethinkDB: Column Alias 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,302,462,466,523],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3278"}],"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=3278"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3278\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}