Core: Is it possible using function selectRaw in Adonis?

Created on 14 Feb 2018  路  3Comments  路  Source: adonisjs/core

I have query:
select user_id, sum(total) as total from transaction group by user_id
Currently, in adonis i will write code like this
await Database.raw('select user_id, sum(total) as total from transaction group by user_id')

Hopefully next time you can add function selectRaw, so my code will be simpler like this:
await Database.table('transaction').selectRaw('user_id, sum(total) as total').groupBy('user_id')

Most helpful comment

How about

Database.table('transaction').select('user_id').sum('total as total').groupBy('user_id')

All 3 comments

How about

Database.table('transaction').select('user_id').sum('total as total').groupBy('user_id')

Thanks @thetutlage.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PC-HUB picture PC-HUB  路  4Comments

codingphasedotcom picture codingphasedotcom  路  3Comments

devcaststudio picture devcaststudio  路  3Comments

imperez picture imperez  路  4Comments

begueradj picture begueradj  路  3Comments