Dart ToMany relation在link()处给出类型错误
我有一张桌子:Dart ToMany relation在link()处给出类型错误,dart,objectbox,Dart,Objectbox,我有一张桌子: @Entity() @JsonSerializable() 类DateTimeStruct{ @JsonKey(忽略:true) int id=0; DateTime=DateTime.now(); 字符串?标题; DateTimeStruct(); 工厂DateTimeStruct.fromJson(映射json)=>\uU$DateTimeStructFromJson(json); 映射到JSON()=>u$DateTimeStructToJson(此); } 及 @Jso
@Entity()
@JsonSerializable()
类DateTimeStruct{
@JsonKey(忽略:true)
int id=0;
DateTime=DateTime.now();
字符串?标题;
DateTimeStruct();
工厂DateTimeStruct.fromJson(映射json)=>\uU$DateTimeStructFromJson(json);
映射到JSON()=>u$DateTimeStructToJson(此);
}
及
@JsonSerializable(explicitToJson:true)
@实体()
班级活动{
最后一次=汤姆尼();
}
当我尝试使用链接查询相关表时,如下所示:
Store.box().query().link(事件时间、,
DateTimeStruct_uu.time.greaterequal(DateTime.now().millissecondssinceepoch));
我明白了
The argument type 'QueryRelationMany<Event, DateTimeStruct>' can't be assigned to the parameter type 'QueryRelationProperty<Event, DateTimeStruct>'
无法将参数类型'QueryRelationMany'分配给参数类型'QueryRelationProperty'
错误消息
第二个问题:DateTimeStruct\uuuu.time
解析为QueryIntegerProperty time
,但它是一个DateTime。是否已在数据库中转换为整数
发布运行生成\u运行生成
,因为事件
缺少id
——如果您想为每个事件
存储多个DateTimeStruct
,您只需要确保您知道。如果每个事件只有一个时间是可以的(从概念上讲,这对我来说是正确的),请使用ToOne
ToMany
,您需要使用.linkMany()
而不是.link()
,这就是编译错误的来源DateTime
对象存储为毫秒时间戳(除非您使用@Property(type:PropertyType.dateNano)注释
另行指定)。您需要这样查询它们-您似乎这样做是正确的谢谢你,瓦因。请刷新文档,这里有一个ToMany with link()dart示例。