Use Multi.run to compose sequential db operations.
For example, we perform 3 different get_by db queries in get_delegation!/5, in lib/liquid_voting/delegations.ex, before a final get_by to find the delegation.
Multi.run could be used here, and any for other similarly sequential db operations. It has many advantages, one of which being that it "saves multiple round trips to the database".
For an example of Multi.run, see create_delegation/1 (the clause that uses emails), also in lib/liquid_voting/delegations.ex.
Use
Multi.runto compose sequential db operations.For example, we perform 3 different
get_bydb queries inget_delegation!/5, inlib/liquid_voting/delegations.ex, before a finalget_byto find the delegation.Multi.runcould be used here, and any for other similarly sequential db operations. It has many advantages, one of which being that it "saves multiple round trips to the database".For an example of
Multi.run, seecreate_delegation/1(the clause that uses emails), also inlib/liquid_voting/delegations.ex.