ReQL could benefit from having an `alias` command. For instance, MySQL has the following command, which allows for column names to be returned with another name. ```MySQL SELECT column_name AS alias_name FROM table_name; ``` Currently, this can be achieved in ReQL by the following method. ```JavaScript r .db('database') .table('table') .map( function(document) { return document.merge( { alias: document('key') } ) } ) .without('key') ``` This is very verbose, and could be simplified with an `alias` command, as follows. ```JavaScript r .db('database') .table('table') .alias('key', 'alias') ``` The `alias` command could also accept an object of aliases. ```JavaScript r .db('database') .table('table') .alias( { keyA: 'aliasA', keyB: 'aliasB', keyC: 'aliasC' } ) ``` An `alias` command could also have the benefit of conveying greater meaning at a glance than an ambiguous `map`.
Activity
chrisvariety commentedon Apr 16, 2017
You can also write an alias like this, which is slightly less verbose.
srh commentedon May 17, 2017
This is a dupe of #881.