Skip to content

Many to many relationship in combination with .watch() #1621

Answered by simolus3
mawilms asked this question in Q&A
Discussion options

You must be logged in to vote

So the thing about await for it is that it keeps going until the stream is done. With drift, you get a never-ending stream of snapshots, so the await for will never complete (well, until the database is closed, but that's not helpful).

Looking at your code, it looks like you want to combine the the planQuery and the joinQuery streams into one. For this purpose, I suggest using helpers from the rxdart package:

Stream<List<TrainingPlanEntity>> watchAllTrainingPlans({bool custom = false}) {
  var planQuery = (select(trainingPlans)
        ..where((tbl) => tbl.custom.equals(custom)))
      .watch();
  var joinQuery = select(trainingPlanExercises).join([
    innerJoin(
        exercises, exerc…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mawilms
Comment options

Answer selected by mawilms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants