且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

按DocumentDB中的字段分组

更新时间:2023-02-15 12:16:20

DocumentDB当前不支持GROUP BY或任何其他聚合.它是第二个要求最多的功能,在 DocumentDB UserVoice 上被列为审核中".

DocumentDB currently does not support GROUP BY nor any other aggregation. It is the second most requested feature and is listed as "Under Review" on the DocumentDB UserVoice.

同时, documentdb-lumenize 是一个DocumentDB的聚集库,以存储方式编写程序.您将cube.string作为存储过程加载,然后使用聚合配置调用它.这个例子有点过分,但是完全有能力完成您在这里要问的事情.如果将其传递给存储过程:

In the mean time, documentdb-lumenize is an aggregation library for DocumentDB written as a stored procedure. You load cube.string as a stored procedure, then you call it with an aggregation configuration. It's a bit overkill for this example, but it's perfectly capable of doing what you are asking here. If you pass this into the stored procedure:

{cubeConfig: {groupBy: "name", field: "priority", f: "max"}}

那应该做你想要的.

请注意,Lumenize的功能远不止于简单的分组方法以及其他功能(总和,计数,最小值,最大值,中位数,p75等),数据透视表,以及直至复杂的n-每个单元具有多个度量的三维超立方体.

Note, Lumenize can do a lot more than that including simple group-by's with other function (sum, count, min, max, median, p75, etc.), pivot tables, and all the way up to complicated n-dimensional hypercubes with multiple metrics per cell.

我从未尝试过从.NET加载cube.string,因为我们使用的是node.js,但是它以字符串而不是JavaScript的形式提供,因此您可以轻松地加载和发送它.

I have never tried loading cube.string from .NET because we're on node.js, but it is shipped as a string rather than javascript so you can easily load and send it.

或者,您可以编写一个存储过程来进行这种简单的聚合.

Alternatively, you could write a stored procedure to do this simple aggregation.