Skip to main content

JsonExprExt

Trait JsonExprExt 

Source
pub trait JsonExprExt<'a>: Expr<'a, PostgresValue<'a>> + Sized {
    // Provided methods
    fn json_get(
        self,
        key: &'a str,
    ) -> SQLExpr<'a, PostgresValue<'a>, Json, Null, Scalar> { ... }
    fn json_get_idx(
        self,
        index: i32,
    ) -> SQLExpr<'a, PostgresValue<'a>, Json, Null, Scalar> { ... }
    fn json_get_text(
        self,
        key: &'a str,
    ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Scalar> { ... }
    fn json_get_text_idx(
        self,
        index: i32,
    ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Scalar> { ... }
    fn json_get_path(
        self,
        path: &'a str,
    ) -> SQLExpr<'a, PostgresValue<'a>, Json, Null, Scalar> { ... }
    fn json_get_path_text(
        self,
        path: &'a str,
    ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Scalar> { ... }
    fn jsonb_contains<R>(
        self,
        other: R,
    ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, Scalar>
       where R: ToSQL<'a, PostgresValue<'a>> { ... }
    fn jsonb_contained<R>(
        self,
        other: R,
    ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, Scalar>
       where R: ToSQL<'a, PostgresValue<'a>> { ... }
    fn jsonb_exists_key(
        self,
        key: &'a str,
    ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, Scalar> { ... }
}
Expand description

Extension trait providing method-based JSON operators for PostgreSQL expressions.

Provided Methods§

Source

fn json_get( self, key: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, Json, Null, Scalar>

Get JSON object field by key (-> operator), returns JSON.

Source

fn json_get_idx( self, index: i32, ) -> SQLExpr<'a, PostgresValue<'a>, Json, Null, Scalar>

Get JSON array element by index (-> operator), returns JSON.

Source

fn json_get_text( self, key: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Scalar>

Get JSON object field as text (->> operator).

Source

fn json_get_text_idx( self, index: i32, ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Scalar>

Get JSON array element as text (->> operator).

Source

fn json_get_path( self, path: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, Json, Null, Scalar>

Get JSON object at path (#> operator), returns JSON.

Source

fn json_get_path_text( self, path: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, Text, Null, Scalar>

Get JSON object at path as text (#>> operator).

Source

fn jsonb_contains<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, Scalar>
where R: ToSQL<'a, PostgresValue<'a>>,

JSONB contains (@> operator).

Source

fn jsonb_contained<R>( self, other: R, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, Scalar>
where R: ToSQL<'a, PostgresValue<'a>>,

JSONB is contained by (<@ operator).

Source

fn jsonb_exists_key( self, key: &'a str, ) -> SQLExpr<'a, PostgresValue<'a>, Boolean, NonNull, Scalar>

JSONB key exists (? operator).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, E: Expr<'a, PostgresValue<'a>>> JsonExprExt<'a> for E

Blanket implementation for all PostgreSQL Expr types.