Field

Field attribute gives the query struct field information.

There are two types of field attributes:


👉 For queries field


  #[field(column_name, param, scalar)]

ArgumentOptionalDescription
column_nameyesThe name of the edgeDB table column represented by the field.

By default: the name of the field
paramyesThe query parameter name.

By default: the name of the field
scalaryesThe field scalar type (example : "default::str").

By default: the scalar type corresponding to the field type
link_property (bool)yesMarks 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)]

ArgumentOptionalDescription
column_nameyesThe name of the edgeDB table column represented by the field.

By default: the name of the field
wrapper_fnyesThe function to apply to the field value
defaut_valueyesThe result field default value
link_property (bool)yesMarks 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
    }