How does one rename the columns on a query to mongodb?
This should not permanently alter the columns for future queries or in the database (non-persistent) but rather just for the query
The functionality that I am looking for is similar to SQL’s ‘AS’ as used in SELECT col1 AS a, col2 as b, col1 as c FROM table
I am aware that this can be rather trivially processed by the application but was just curious as to how this is implemented in mongodb
The aggregation framework can achieve a similar functionality:
It is also possible to filter on a certain conditions by adding a $match in the pipeline:
That said, as the aggregation framework has some limitations, processing this in the application should be a better choice.