Loopback 4-如何在列中找到最高值(例如表格中的最大值(列))?
我想在特定表的特定列中找到最高值。它应该非常简单。 这是lb4 https://loopback.io/doc/doc/en/lb2/在哪里进行滤波器,但我在那里没有找到它。
I want to find the highest value in a specific column of a specific table. It should be very simple.
this is the documentation of LB4 https://loopback.io/doc/en/lb2/Where-filter But I didn't find it there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们通过一种自定义存储库方法来执行此操作,在该方法中,我们执行一个select max()查询,并具有调用它的自定义控制器方法(IE /Next-ID)。
存储库方法:
控制器方法:
We did this through a custom repository method where we execute a select max() query and have a custom controller method (i.e. /next-id) that calls it.
Repository method:
Controller method:
在 loopback filter文档即使不是那么明显的方法,即使它并不那么明显。
本质上,您可以执行以下操作:
gt
运算符设置最小号码订单
。将结果限制为1。这是一个代码示例:
请让我知道这是否是您想要的,或者是否需要更多支持。
Within the Loopback Filter Documentation they do mention a way to achieve this, even though it's not as obvious.
Essentially you can do the following:
gt
operator to set a min numberorder
if you wanted to ensure the sorting order is as expected.Here is a code example:
Please let me know if this is what you were going for or if you need some more support.