Field
Field attribute gives the query struct field information.
There are two types of field attributes:
👉 For queries field
#[field(column_name, param, scalar)]
Argument | Optional | Description |
---|---|---|
column_name | yes | The name of the edgeDB table column represented by the field. By default: the name of the field |
param | yes | The query parameter name. By default: the name of the field |
scalar | yes | The field scalar type (example : "default::str"). By default: the scalar type corresponding to the field type |
link_property (bool) | yes | Marks a field as link property. By default: false |
Usage
struct InsertUser {
#[field(column_name= "first_name", param = "username", scalar = "<default::str>")]
name: String
}
👉 For query result field
#[field(column_name, wrapper_fn, default_value)]
Argument | Optional | Description |
---|---|---|
column_name | yes | The name of the edgeDB table column represented by the field. By default: the name of the field |
wrapper_fn | yes | The function to apply to the field value |
defaut_value | yes | The result field default value |
link_property (bool) | yes | Marks a field as link property. By default: false |
Usage
struct UserResult {
#[field(column_name= "first_name", wrapper_fn ="str_upper", default_value="John")]
name: String
}