dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Set static value for .call function #624

Closed devoll closed 9 years ago

devoll commented 9 years ago

Hello guys,

I want to use MySQL function DATE_FORMAT, but I don't know how to use static value (not a column name):

events.aggregate(['status_date'])
                        .call('DATE_FORMAT', ['status_date', '%Y-%m-%d']).as('dt')
                        .count('id')
                        .groupBy('dt')
                        .get(callback);

Do you have any ideas?

Thanks!

devoll commented 9 years ago

I have solution. Just use orm.Text():

events.aggregate(['status_date'])
                        .call('DATE_FORMAT', ['status_date', orm.Text('%Y-%m-%d')]).as('dt')
                        .count('id')
                        .groupBy('dt')
                        .get(callback);