-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
groupBy datetime #204
Comments
Can you show me an sql example? |
ORM still does not support it, I have to think how to do it. If you have any idea of how this could be done please post an example. |
If I see it correct ORM does not use the I'm thinking about either a general support for the fun method or a special implementation with strftime. |
Yes, it doesn't use it but maybe it should, or... the drivers should. Or at least expose it. |
In Locke/node-orm2 and Locke/node-sql-query I simply added strftime to the aggregation functions and can now group via: Model.aggregate().count().strftime([ query.Text('%Y-%m-%d'), 'date' ]).groupBy('strftime_date').get(...) I don't know if it's compatible with all drivers, therefore I updated only the sqlite driver. As this is a lot of typing I could imagine adding wrappers like |
I just don't want to add strftime directly, I want to expose the generic function call. And have also to expose the |
I would expose strftime if it was generic or have the same function across drivers (even if it had different names). |
…l() in aggregates for generic functions (#204)
You can now call any supported function like this: Person.aggregate().call("strftime", [ orm.Text('%Y-%m-%d'), 'date' ]).as('dt').groupBy('dt').get(function () {
console.log(arguments);
}); The Please try the latest commit and see if it works for you. |
Great, in my testcase that works fine. I still need to deploy that into my
|
Depending on dresende/node-sql-query#10 I want to group by a DATETIME field and want to pass the format string to be able to group by a day, year or even an hour.
The text was updated successfully, but these errors were encountered: