Skip to main content

json_object_agg

Function json_object_agg 

Source
pub fn json_object_agg<'a, V, K, Val>(
    key: K,
    value: Val,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Json, 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 JSON object (JSON_OBJECT_AGG), on PostgreSQL.

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

ยงExamples

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