Skip to content

Commit

Permalink
add where_in to query
Browse files Browse the repository at this point in the history
  • Loading branch information
m1guelpf committed Oct 30, 2023
1 parent 7dc7e86 commit 56fe7ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions ensemble/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ impl Builder {
self
}

// Add a "where in" clause to the query.
#[must_use]
pub fn where_in<T>(mut self, column: &str, values: Vec<T>) -> Self
where
T: Into<Value>,
{
self.r#where.push(WhereClause::Simple(Where {
boolean: Boolean::And,
operator: Operator::In,
column: column.to_string(),
value: Some(Value::Array(values.into_iter().map(Into::into).collect())),
}));

self
}

/// Add a "where is null" clause to the query.
#[must_use]
pub fn where_null(mut self, column: &str) -> Self {
Expand Down
1 change: 0 additions & 1 deletion examples/user/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub struct User {
pub id: u64,
pub name: String,
pub email: String,
#[validate(length(min = 8))]
pub password: Hashed<String>,
pub created_at: DateTime,
pub updated_at: DateTime,
Expand Down

0 comments on commit 56fe7ab

Please sign in to comment.