我正在尝试使用nodejs-ravendb-client在ravendb上执行groupBy
查询!
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)
上遇到此错误
这里有帮助吗?
答案 0 :(得分:4)
文档查询的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: