我正在尝试使用 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)
这里有任何帮助吗?
文档查询的 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();
有关更多详细信息和示例,请参阅官方文档: