Attribute Macro butane::dataresult
source · #[dataresult]
Expand description
Attribute macro which generates an implementation of
DataResult
. Continuing with our blog
post example from model, we could create a DataResult
with
only some of the fields from Post
(to avoid fetching all of them in a query).
ⓘ
#[dataresult(Post)]
pub struct PostMetadata {
pub id: i64,
pub title: String,
pub pub_time: Option<NaiveDateTime>,
}
Note that the attribute takes a parameter saying which Model this result is a subset of. Every field named in the DataResult must be present in the Model.