Function diesel::expression::dsl::exists [] [src]

pub fn exists<T: AsQuery>(query: T) -> Exists<T::Query>

Creates a SQL EXISTS expression.

The argument must be a complete SQL query. The result of this could in theory be passed to .filter, but since the query cannot reference columns from the outer query, this is of limited usefulness.

Example

let sean_exists = select(exists(users.filter(name.eq("Sean"))))
    .get_result(&connection);
let jim_exists = select(exists(users.filter(name.eq("Jim"))))
    .get_result(&connection);
assert_eq!(Ok(true), sean_exists);
assert_eq!(Ok(false), jim_exists);