Derive Macro edgedb_derive::Queryable [−][src]
#[derive(Queryable)]
{
// Attributes available to this derive:
#[edgedb]
}
Expand description
Derive macro to allow structs and enums be queried from the database
This derive can be used on structures with named fields (which correspond to “shapes” in EdgeDB).
#[derive(edgedb_client::Queryable)]
struct User {
first_name: String,
age: i32,
}
Field attributes
JSON
The #[edgedb(json)]
decodes a field using serde_json
instead of EdgeDB
binary protocol. Useful if some data is stored in the database as JSON, but
you need to process it. The underlying type must implement
serde::Deserialize
.
#[derive(edgedb_client::Queryable)]
struct User {
#[edgedb(json)]
user_notes: HashMap<String, String>,
}
Container attributes
JSON
The #[edgedb(json)]
can be used to unpack the structure from the JSON.
The underlying type must implement serde::Deserialize
#[derive(edgedb_client::Queryable, serde::Deserialize)]
#[edgedb(json)]
struct JsonData {
field1: String,
field2: u32,
}