DBFlow for android 没有好的文档,在阅读了有关如何在两个表之间建立简单关系的更多信息后,我无法做到这一点。
我有2张桌子:
MainCategories
和SubCategories
在SubCategories
我有channelId
它存储在表中MainCategories
,MainCategories
有更多的数据SubCategories
,(一对多)
现在我正在尝试实现这种关系:
我的代码不正确,与库文档类似
MainCategories
:
@Table(database = AppDatabase.class)
public class ChannelContentCategories extends BaseModel {
@PrimaryKey(autoincrement = true)
private int id;
@Column
private int channelId;
@Column
private String title;
List<ChannelSubContentCategories> subContentCategories;
@OneToMany(methods = {OneToMany.Method.ALL})
public List<ChannelSubContentCategories> getMyChannelSubContentCategoriess() {
...
}
...
}
SubCategories
:
@Table(database = AppDatabase.class)
public class ChannelSubContentCategories extends BaseModel {
@PrimaryKey(autoincrement = true)
private int id;
@Column
private int categoryId;
@Column
private int parentId;
@Column
private String title;
...
}
我怎样才能channelId
在ChannelContentCategories
桌子和parentId
桌子之间建立简单的关系ChannelSubContentCategories
?
提前致谢