Unique count of edges

The problem with SQL is that adding a new relation can be problematic. In dgraph you can add this edge relatively quickly at basically no cost.


I think your problem could also be solved with foreach loop, which is a proposal for now. Then you could loop for each office, get empl for each one; and aggregate/range at the end.

You would be basically looping a query like this, which I think gets what you need for one office:

{
  office(func:type("Office"), first: 1) {
    officename: Office.bezeichnung
    Office.jobs {
      EMPL as Job.employees
    }
  }
  allemplforoffice(func: uid(EMPL)) {
    count(uid)
  }
}
1 Like