sqlx-transparent-json-decode
This crate is meant for use with sqlx and allows you to query JSON or JSONB fields from PostgreSQL without needing to wrap the types in a sqlx::types::Json<>
wrapper type.
use ;
use sqlx_json_decode;
sqlx_json_decode!;
Normally, you would need to use Json<SomeJsonField>
as the type for params
in the above example. This crate allows you to use SomeJsonField
directly.
let result = query_as!.fetch_one.await?;
This crate also provides BoxedRawValue
, a wrapper around Box<serde_json::value::RawValue>
which can be decoded directly. This is
otherwise difficult to do using sqlx's query macros.
let result = query!