Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make better use of Multi.run #237

Open
jinjagit opened this issue Apr 7, 2021 · 0 comments
Open

Make better use of Multi.run #237

jinjagit opened this issue Apr 7, 2021 · 0 comments

Comments

@jinjagit
Copy link
Member

jinjagit commented Apr 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant