pub fn jsonb_exists_key<'a, E>(
expr: E,
key: &'a str,
) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, E::Aggregate, Arg<E::Nullable, E::Sources>>Expand description
Tests whether a key exists at the top level of a jsonb value (?).
The operand must be jsonb (JsonbType). For a jsonb array, the
test matches string elements instead. The result is NULL when the operand is NULL.
ยงExamples
use drizzle_postgres::expr::jsonb_exists_key;
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_key(data, "email");
assert_eq!(cond.to_sql().sql(), "data ? CAST ($1 AS TEXT)");