我正在尝试使用 nodejs-ravendb-client 在 ravendb 上执行 groupBy
查询!
const apmts = await session.query<Appointment>({ collection: "Appointments" })
.statistics(s => (stats = s))
.groupBy("client.name").all();
在 typescript 编译时遇到这个错误
Property 'all' does not exist on type 'IGroupByDocumentQuery<Appointment>'.ts(2339)
这里有什么帮助吗?
最佳答案
文档查询的groupBy()
方法返回类型为IGroupByDocumentQuery
的对象
如您所见,它没有 all()
方法。
您可以使用 selectKey()
、selectCount()
或 selectSum()
进行聚合,然后将其与 all( )
。例如:
const { GroupByField } = require("ravendb");
const orders = await session.query({ collection: "Orders" })
.groupBy("ShipTo.Country")
.selectKey("ShipTo.Country", "Country")
.selectSum(new GroupByField("Lines[].Quantity", "OrderedQuantity"))
.all();
更多细节和例子请引用official documentation :
关于node.js - groupBy 查询与 nodejs ravendb 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55607170/