Skip to main content

jsonb_object_agg

Function jsonb_object_agg 

Source
pub fn jsonb_object_agg<'a, V, K, Val>(
    key: K,
    value: Val,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Jsonb, Null, Agg, (K::Sources, Val::Sources)>
where V: SQLParam + 'a, V::DialectMarker: DialectSupports<PostgresAggregate>, K: Expr<'a, V>, Val: Expr<'a, V>,
Expand description

Collects key/value pairs into a JSONB object (JSONB_OBJECT_AGG), on PostgreSQL.

Accepts any key and value expressions. The result is jsonb, nullable, and an aggregate.

ยงExamples

let by_name = jsonb_object_agg(users.name, users.age);
assert_eq!(by_name.sql(), r#"JSONB_OBJECT_AGG ("users"."name", "users"."age")"#);