3

My Dependencies for moor:

  moor_flutter: ^2.1.1
  moor_ffi: ^0.4.0

I have the tables:

  • netPoint = Information about the netPoint
  • netPointNetPoint = linking of netpoints

I want all netPoints that match the "PARENTS_ID" s. below.

My problem is that I cannot access netPointNetPoint in the Where condition.

select(netPoint)
    ..where((t) => t.TYPE.equals(type))
    ..join(
        [
          innerJoin(netPointNetPoint, netPointNetPoint.CHILDREN_ID.equalsExp(netPoint.ID)),
          innerJoin(netPointNetPoint, netPointNetPoint.PARENTS_ID.equals(parentId))
        ]
    )
  ).get();

Unfortunately the help page https://moor.simonbinder.eu/docs/advanced-features/joins/ did not help me.

osion
  • 93
  • 2
  • 14

2 Answers2

2

Well, the questions is quite old, but I've faced the same problem and just in case some one will have the same problem. I guess you had to change the expressions with something like this:

select(netPoint)
..where((t) => t.TYPE.equals(type))
..where((t) => netPointNetPoint.PARENTS_ID.equals(parentId))
..join(
    [
      innerJoin(netPointNetPoint, netPointNetPoint.CHILDREN_ID.equalsExp(netPoint.ID))
    ]
)).get();

The join's result will have all the columns you need, hence you just need to check that the column in the row has needed value. E.g. netPointNetPoint.PARENTS_ID.equals(parentId).

0

I guess, you are accessing the netPointNetPoint table outside the extended Database class. That will fail as all tables are accessed inside the database.

and I guess, you initialized that database in such a way it is accessible by other files.

if you initialized the database like this :

final AppDatabase db = AppDatabase();

then, to reference your netPointNetPoint table, just do it from the Database object, like this :

db.netPointNetPoint

I think, this will help you

Francis Nduba Numbi
  • 2,499
  • 1
  • 11
  • 22