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

Adds when to query builder #280

Merged
merged 1 commit into from
Dec 28, 2020
Merged

Adds when to query builder #280

merged 1 commit into from
Dec 28, 2020

Conversation

josephmancuso
Copy link
Member

@josephmancuso josephmancuso commented Dec 28, 2020

Closes #277

Adds the ability to use when in the query builder. We can use this to easily conditionally add query statements

age = 21

User.when(age >= 21, lambda q: q.where('age_restricted', 1)).get()

This will result in different queries based on the conditional in the first parameter. If the first parameter is truthy then run the second parameter

@josephmancuso josephmancuso merged commit 2f1c42e into 0.9 Dec 28, 2020
@josephmancuso josephmancuso deleted the feature/277 branch January 23, 2021 22:17
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

Successfully merging this pull request may close these issues.

Add when to query builder
1 participant