Skip to content
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

老兄,DomainModel.query 怎么使用order by 呀。 #52

Open
augustinexx opened this issue Nov 24, 2020 · 6 comments
Open

老兄,DomainModel.query 怎么使用order by 呀。 #52

augustinexx opened this issue Nov 24, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@augustinexx
Copy link

简单查询中,排序是很正常的需求呀,不能用到排序这种简单的查询还需要使用复杂SQL 吧,不是很人性化。
从我的理解看,增加一个排序应该不难呀。

@catchex
Copy link
Member

catchex commented Nov 24, 2020

你好,query 方法中的确没有orderBy, limit 等参数,主要考虑这类参数并不是频繁被使用的,后续根据实际情况调整。
目前,所有DomainModel 中都有一个createQuery 方法,该方法拥有所有查询所需的条件,暂时你可以这样使用

@catchex catchex added documentation Improvements or additions to documentation enhancement New feature or request question Further information is requested labels Nov 24, 2020
@augustinexx
Copy link
Author

大佬,不太对呀,例如下面的代码:

List<Member> members = Members.queryAll();
List<Member> members = Member.query("id > ?", 1);

这里,我可加orderBy 或者limit 等操作,就不行呀,非要去构造Query 太麻烦了。

@yeongher
Copy link
Contributor

yeongher commented Dec 3, 2020

同感!

@catchex
Copy link
Member

catchex commented Dec 3, 2020

的确有点不太合适,针对多行数据的查询,使用到orderBy 或limit 等约束的可能性比较大,我考虑一下再增加一个中间状态的方法,直接返回Query 接口。

@catchex
Copy link
Member

catchex commented Dec 3, 2020

可以作为一个新的Feature 合在下一个版本。

@catchex catchex removed the documentation Improvements or additions to documentation label Dec 3, 2020
@catchex
Copy link
Member

catchex commented Dec 3, 2020

暂时你们先按下列方法编程:

Query query = Member.createQuery();
query.project("name").groupBy("name").having("COUNT(*) > 0").orderBy("name DESC");

List<Member> members = query.execute(Member.HAS_MANY_ORDERS);

@catchex catchex removed the question Further information is requested label Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants