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

建议加个分页功能, 以及加个取分页总数功能 #321

Open
ghost opened this issue Jun 8, 2024 · 3 comments
Open

建议加个分页功能, 以及加个取分页总数功能 #321

ghost opened this issue Jun 8, 2024 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 8, 2024

pageSize := 10 // 设置分页参数
pageNum := 3 // 第3页

cli.Find(ctx, bson.D{{"年龄", bson.M{"$gt": 0}}}).Page(pageNum , pageSize ).All(&users) //分页
cli.Find(ctx, bson.D{{"年龄", bson.M{"$gt": 0}}}).TotalPages(pageSize ) //取分页总数

你不觉得这使用频率好高么. 要不每个地方都得多写好几行.

@luoqichen
Copy link

skip+limit可以实现呀,单独写个函数好像没有这个必要

@nuan1989
Copy link

nuan1989 commented Nov 6, 2024

跟我想到一块去了. 我就自己弄了一个函数

@luoqichen
Copy link

我已经想到了。 我就自己弄了一个函数

go中就这个用起来比较舒服

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants