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

优化Limit的调用 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

优化Limit的调用 #1

wants to merge 1 commit into from

Conversation

armingli
Copy link
Owner

@armingli armingli commented Mar 9, 2020

要用到分布逻辑时,经常要根据limit要写条件,类似这样的

if param.Limit > 0 {
		err = session.Limit(int(param.Limit), int(param.Start)).Find(&list)
	} else {
		err = session.Find(&list)
	}

Limit方法中判断limit值,调用方可不用关心limit的大小

要用到分布逻辑时,经常要根据limit要写条件,类似这样的

```go
if param.Limit > 0 {
		err = session.Limit(int(param.Limit), int(param.Start)).Find(&list)
	} else {
		err = session.Find(&list)
	}
```

在`Limit`方法中判断limit值,调用方可不用关心limit的大小
@armingli armingli added the enhancement New feature or request label Mar 9, 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

Successfully merging this pull request may close these issues.

1 participant