Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Einliterflasche committed May 21, 2023
1 parent 2c2ce7f commit 69616a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pg-worm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,23 @@ impl<T: ToSql + Sync + Send + 'static> Column<T> {
}
}

/// Check whether the columns value is equal to `value`.
///
/// Translates to `WHERE <column_name> = <value>`.
pub fn eq(&self, value: impl Into<T>) -> Filter {
Filter::new(format!("{} = $1", self.name), vec![Box::new(value.into())])
}

/// Check whether the columns value is not equalt to `value`
///
/// Tranlates to `WHERE <column_name> != <value>`.
pub fn neq(&self, value: impl Into<T>) -> Filter {
Filter::new(format!("{} != $1", self.name), vec![Box::new(value.into())])
}

/// Check whether the columns value is one of `values`.
///
/// Translates to `WHERE <column_name> IN <values>`
pub fn one_of(&self, values: Vec<impl Into<T>>) -> Filter {
// Early return if no values are supplied
if values.is_empty() {
Expand All @@ -451,6 +460,9 @@ impl<T: ToSql + Sync + Send + 'static> Column<T> {
Filter::new(format!("{} IN ({placeholders})", self.name), vals)
}

/// Check whether the columns value is not one of `values`.
///
/// Translates to `WHERE <column_name> NOT IN <values>`
pub fn none_of(&self, values: Vec<impl Into<T>>) -> Filter {
// Early return if no values are supplied
if values.is_empty() {
Expand Down

0 comments on commit 69616a4

Please sign in to comment.