From 56fe7ab92f097504dd63cdf07f7aa3e9560abe95 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Mon, 30 Oct 2023 01:59:37 +0000 Subject: [PATCH] add where_in to query --- ensemble/src/query.rs | 16 ++++++++++++++++ examples/user/src/main.rs | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ensemble/src/query.rs b/ensemble/src/query.rs index ffea79b..3b9db29 100644 --- a/ensemble/src/query.rs +++ b/ensemble/src/query.rs @@ -160,6 +160,22 @@ impl Builder { self } + // Add a "where in" clause to the query. + #[must_use] + pub fn where_in(mut self, column: &str, values: Vec) -> Self + where + T: Into, + { + 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 { diff --git a/examples/user/src/main.rs b/examples/user/src/main.rs index eef3401..d69656f 100644 --- a/examples/user/src/main.rs +++ b/examples/user/src/main.rs @@ -10,7 +10,6 @@ pub struct User { pub id: u64, pub name: String, pub email: String, - #[validate(length(min = 8))] pub password: Hashed, pub created_at: DateTime, pub updated_at: DateTime,