Trait sea_orm::entity::prelude::QueryFilter[][src]

pub trait QueryFilter: Sized {
    type QueryStatement: ConditionalStatement;
    fn query(&mut self) -> &mut Self::QueryStatement;

    fn filter<F>(self, filter: F) -> Self
    where
        F: IntoCondition
, { ... }
fn belongs_to<M>(self, model: &M) -> Self
    where
        M: ModelTrait
, { ... } }

Associated Types

Required methods

Provided methods

Add an AND WHERE expression

use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};

assert_eq!(
    cake::Entity::find()
        .filter(cake::Column::Id.eq(4))
        .filter(cake::Column::Id.eq(5))
        .build(DbBackend::MySql)
        .to_string(),
    "SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` = 4 AND `cake`.`id` = 5"
);

Add a condition tree.

use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};

assert_eq!(
    cake::Entity::find()
        .filter(
            Condition::any()
                .add(cake::Column::Id.eq(4))
                .add(cake::Column::Id.eq(5))
        )
        .build(DbBackend::MySql)
        .to_string(),
    "SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` = 4 OR `cake`.`id` = 5"
);

Apply a where condition using the model’s primary key

Implementors