我正在尝试使用groupBy
在ravendb上执行nodejs-ravendb-client查询!
const apmts = await session.query<Appointment>({ collection: "Appointments" })
.statistics(s => (stats = s))
.groupBy("client.name").all();
在打字稿上面对这个错误编译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: