Skip to main content

jsonb_exists_any

Function jsonb_exists_any 

Source
pub fn jsonb_exists_any<'a, E>(
    expr: E,
    keys: &[&'a str],
) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, E::Aggregate, Arg<E::Nullable, E::Sources>>
where E: Expr<'a, PostgresValue<'a>>, E::SQLType: JsonbType,
Expand description

Tests whether any of the keys exists at the top level of a jsonb value (?|).

The operand must be jsonb (JsonbType). The keys are bound as one text[] parameter. The result is NULL when the operand is NULL.

ยงExamples

use drizzle_postgres::expr::jsonb_exists_any;
use drizzle_core::{ToSQL, expr::raw_non_null};
use drizzle_postgres::values::PostgresValue;
use drizzle_types::postgres::types::Jsonb;

let data = raw_non_null::<PostgresValue, Jsonb>("data");
let cond = jsonb_exists_any(data, &["email", "phone"]);
assert_eq!(cond.to_sql().sql(), "data ?| $1");