Decorator
Decorator is the thing begins with an at sign. It modifies the definition or behavior of the decorated item.
model User {
@id
id: Int
}
Available decorators are:
- Model decorator REFERENCE
- Model field decorator REFERENCE
- Model relation decorator REFERENCE
- Model property decorator REFERENCE
- Handler decorator REFERENCE
Decorator declaration
To declare a new decorator in the schema, use the declare syntax:
declare model decorator markSpecial(altName: String?)
Decorator implementation
Decorator requires server implementation. See:
- Namespace REFERENCE
app.main_namespace().define_model_field_decorator("markSpecial", |arguments: Arguments, model: &mut Model| {
let altName: Option<String> = arguments.get_optional("altName")?;
model.data.insert("altName".to_owned(), Value::from(altName));
Ok(())
});