我有一个表类别,它与一对多关系中的任务表相关,我正在尝试使用 Moor 执行连接。
我想返回一个与类别匹配的任务列表。我该怎么做?
Stream<List<CategoryWithTask>> watchAllCategories() {
return (select(categories)
..orderBy(([
(c) => OrderingTerm(expression: c.name),
])))
.join([leftOuterJoin(tasks, tasks.categoryId.equalsExp(categories.id))])
.watch()
.map((rows) => rows.map(
(row) {
return CategoryWithTask(
category: row.readTable(categories),
task: row.readTable(tasks)); // How do I modify this line to return a list of tasks corresponding to a category?
},
).toList());
}