从过滤结果集中的hotchocaly差异值

发布于 2025-02-11 05:44:55 字数 2487 浏览 3 评论 0原文

我有一张SQL桌子看起来像:

ID产品用户状态创建日期
1奶酪JohnNew2022-02-07
2牛奶Stevepergend redend redend redend2022-06-12
3JuiceSteve SteveNew2022-06-10
4BeerLloyd完成2021-12-01
5苹果路易斯完成2022-05-10
6橙子约翰待定2022-05-10
7胡萝卜约翰·2022-06-238
CookiesFred取消2021-11-07
9JellyLuis2021-05-30

在网页上 在网页上,I AM在页面中显示此表,3个项目:

第1页:

ID产品用户状态创建日期
1奶酪JohnNew2022-02-07
2牛奶Steveperdeve pernew2022-06-12
3JuiceSteve Steve SteveNew2022-06-10

Page 2:

ID产品用户状态创建日期
4啤酒劳埃德完成2021-12-01
5ApplesLuis完成2022-05-10
6ORANGESJOHN JOHNpENDENG2022-05-10

等。

现在,使用ODATA查询,我可以使用此类疑问过滤此表:

/odata/products?$filter=Status eq 'New'

/odata/products?$filter=CreatedDate eq '2022-05-10'

I i我正在动态创建这样的过滤器。

现在,对于已过滤或未经过滤的结果,我想检索例如用户或状态的不同列表:

  • 要获取状态“ new”的用户列表,我正在发送此odata查询:/odata/products。 ?$ apply = filter(状态eq'new')/groupby((用户))
  • 要获取所选用户的不同状态列表,我正在发送此odata查询:/odata/products?$ $ apply = filter(用户eq'steve')/groupby((状态))

我如何使用GraphQl实现类似的东西,尤其是使用Hotchocaly?

接收过滤结果很简单 - 只需通过过滤和分页创建查询即可。 但是,从过滤数据集中检索不同的值呢?这样的查询不得使用分页 - 我们应该从所有页面中获得不同的值,而不仅仅是第2页。

I have a sql table looking like this:

IDProductUserStatusCreatedDate
1CheeseJohnNew2022-02-07
2MilkStevePending2022-06-12
3JuiceSteveNew2022-06-10
4BeerLloydFinished2021-12-01
5ApplesLuisFinished2022-05-10
6OrangesJohnPending2022-05-10
7CarrotsJohnNew2022-06-23
8CookiesFredCanceled2021-11-07
9JellyLuisPending2021-05-30

On web page, I am showing this table in pages, by 3 item:

Page 1:

IDProductUserStatusCreatedDate
1CheeseJohnNew2022-02-07
2MilkStevePending2022-06-12
3JuiceSteveNew2022-06-10

Page 2:

IDProductUserStatusCreatedDate
4BeerLloydFinished2021-12-01
5ApplesLuisFinished2022-05-10
6OrangesJohnPending2022-05-10

etc.

Now, using odata query, I can filter this table using such query:

/odata/products?$filter=Status eq 'New'

or

/odata/products?$filter=CreatedDate eq '2022-05-10'

I am creating such filters dynamically.

Now, for filtered or unfiltered results I would like to retrieve distinct list of, for example, Users or Statuses:

  • to get distinct list of Users for status 'New' I am sending for example this odata query: /odata/products?$apply=filter(Status eq 'New')/groupby((User))
  • to get distinct list of Statuses for selected User I am sending for example this odata query: /odata/products?$apply=filter(User eq 'Steve')/groupby((Status))

How can I achieve something similar using graphql, especially with HotChocolate?

Receiving filtered results are simple - just create a query with filtering and paging.
But what about retrieving distinct values from filtered dataset? Such a query must not use paging - we should get distinct values from all pages, not just from page 2 for instance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文