You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There isn't. I started the project as a way for people to completely avoid using sql but now I'm thinking about having that possibility (with a warning about compatibility if switching to other dbms).
This is probably going to appear a little odd, perhaps we can shorten the code in the future. I added DISTINCT to sql-query dependency and updated ORM. Also, added .as() to add aliases to functions instead of the auto-generated (if needed). Here's an example:
Person.aggregate().distinct('country').as('country').groupBy('country').get(function(err,countries){// groupBy is needed or else it will return only the first one});
As you can see, .groupBy shouldn't be needed since the query with or without it should return the same thing, but ORM returns only one row for aggregate functions when not using .groupBy.
Activity
dresende commentedon Apr 15, 2013
There isn't. I started the project as a way for people to completely avoid using sql but now I'm thinking about having that possibility (with a warning about compatibility if switching to other dbms).
dresende commentedon Apr 15, 2013
About the distinct, that's the query you want to do (in your example) or a more complex one? I was thinking about the aggregation functions..
huangyingjie commentedon Apr 16, 2013
just the distinct. Using sql while some functions have not been developped.
Adds aggregate .as() to define alias to previous function (#123)
Adds DISTINCT function to all drivers (#123)
dresende commentedon Apr 16, 2013
This is probably going to appear a little odd, perhaps we can shorten the code in the future. I added
DISTINCTtosql-querydependency and updated ORM. Also, added.as()to add aliases to functions instead of the auto-generated (if needed). Here's an example:As you can see,
.groupByshouldn't be needed since the query with or without it should return the same thing, but ORM returns only one row for aggregate functions when not using.groupBy.dresende commentedon Apr 16, 2013
This is because
DISTINCTis not actually an aggregate function (I think!) but it works well with them.huangyingjie commentedon Apr 17, 2013
Acturally it is a bit odd, we use it temporarily.
Adds exception for .distinct() to behave a little different from othe…
dresende commentedon Apr 17, 2013
You should now be able to do:
dresende commentedon Apr 17, 2013
If you have a more complex query please post it, I'm not sure how it handles it using more functions.