Struct SelectBuilder

Source
pub struct SelectBuilder { /* private fields */ }

Implementations§

Source§

impl SelectBuilder

Source

pub fn new(from: &str) -> Self

Create a new select query for a given table

§Examples
use postgres_querybuilder::SelectBuilder;

let mut builder = SelectBuilder::new("users");
Source

pub fn select(&mut self, column: &str) -> &mut Self

Add a column to select

§Examples
use postgres_querybuilder::SelectBuilder;
use postgres_querybuilder::prelude::QueryBuilder;

let mut builder = SelectBuilder::new("users");
builder.select("id");
builder.select("email");

assert_eq!(builder.get_query(), "SELECT id, email FROM users");
Source

pub fn add_where_raw(&mut self, raw: String) -> &mut Self

Add a raw where condition

§Examples
use postgres_querybuilder::SelectBuilder;
use postgres_querybuilder::prelude::QueryBuilder;

let mut builder = SelectBuilder::new("users");
builder.add_where_raw("something IS NULL".into());

assert_eq!(builder.get_query(), "SELECT * FROM users WHERE something IS NULL");

Trait Implementations§

Source§

impl QueryBuilder for SelectBuilder

Source§

fn add_param<T: 'static + ToSql + Sync + Clone>(&mut self, value: T) -> usize

Source§

fn get_query(&self) -> String

Source§

fn get_ref_params(self) -> Vec<&'static (dyn ToSql + Sync)>

Source§

impl QueryBuilderWithGroupBy for SelectBuilder

Source§

fn group_by(&mut self, field: &str) -> &mut Self

Source§

impl QueryBuilderWithJoin for SelectBuilder

Source§

fn inner_join(&mut self, table_name: &str, relation: &str) -> &mut Self

Source§

fn left_join(&mut self, table_name: &str, relation: &str) -> &mut Self

Source§

fn left_outer_join(&mut self, table_name: &str, relation: &str) -> &mut Self

Source§

impl QueryBuilderWithLimit for SelectBuilder

Source§

fn limit(&mut self, limit: i64) -> &mut Self

Source§

impl QueryBuilderWithOffset for SelectBuilder

Source§

fn offset(&mut self, offset: i64) -> &mut Self

Source§

impl QueryBuilderWithOrder for SelectBuilder

Source§

fn order_by(&mut self, field: Order)

Add order attribute to request

§Examples
use postgres_querybuilder::SelectBuilder;
use postgres_querybuilder::prelude::Order;
use postgres_querybuilder::prelude::QueryBuilder;
use postgres_querybuilder::prelude::QueryBuilderWithOrder;

let mut builder = SelectBuilder::new("users");
builder.order_by(Order::Asc("name".into()));

assert_eq!(builder.get_query(), "SELECT * FROM users ORDER BY name ASC");
Source§

impl QueryBuilderWithQueries for SelectBuilder

Source§

fn with_query(&mut self, name: &str, query: &str) -> &mut Self

Source§

impl QueryBuilderWithWhere for SelectBuilder

Source§

fn where_condition(&mut self, raw: &str) -> &mut Self

Add where condition to query Read more
Source§

fn where_eq<T: 'static + ToSql + Sync + Clone>( &mut self, field: &str, value: T, ) -> &mut Self

Add where equal condition to query Read more
Source§

fn where_ne<T: 'static + ToSql + Sync + Clone>( &mut self, field: &str, value: T, ) -> &mut Self

Add where not equal condition to query Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V