我有以下要在Android中使用的文档:
用户:
{"Type" : "User", "UserId" : 920, "InitialCommitment": 2000, "BlockId": 1, "_id" : "User_1_920"},
{"Type" : "User", "UserId" : 921, "InitialCommitment": 1800, "BlockId": 1, "_id" : "User_1_921"}
在Type_BlockId_UserId中形成ID的位置
兴趣:
{"Type" : "Intr", "UserId" : 920, "IntrId":1, "Value": 11, "BlockId": 1, "_id" : "Intr_1_920_1"},
{"Type" : "Intr", "UserId" : 920, "IntrId":2, "Value": 5, "BlockId": 1, "_id" : "Intr_1_920_2"}
其中id是Intr_BlockId_UserId_IntrId
基本上,我想通过BlocKId获得聚合数据,如下所示:
BlocKId: 1, totalCommitments:3800, totalInterests: 16
我在Type,UserId,IntrId和BlockId字段上都有索引。我现在的问题是我的应用程序不编译,因为Sum函数不存在。其次,我正在做两个查询,一个是获取利息汇总,另一个是承诺汇总。是否可以一次性加入查询?
val queryTotalCommitment: Query = QueryBuilder.select(
SelectResult.expression(Function.Sum(Expression.property("InitialCommitment"))),
SelectResult.property("BlockId"),
.from(DataSource.database(database))
.groupBy(
Expression.property("BlockId"))
val queryTotalInterests: Query = QueryBuilder.select(
SelectResult.expression(Function.Sum(Expression.property("Value"))),
SelectResult.property("BlockId"),
.from(DataSource.database(database))
.groupBy(
Expression.property("BlockId"))
现在错误是Sum不存在。我应该写吗?我已经从chairbaste.lite导入了功能
是因为科特林。它在Java中效果很好,因为从子类中可以看到非公共超级类的公共成员,而Kotlin则不是。 HERE IS MORE