Struct ormlite_attr::ColumnAttributes
source · pub struct ColumnAttributes {
pub primary_key: Flag,
pub insertable_primary_key: Flag,
pub default: Flag,
pub default_value: Option<NameValue<LitStr>>,
pub join_column: Option<NameValue<LitStr>>,
pub many_to_many_table: Option<Ident>,
pub one_to_many_foreign_key: Option<Path>,
pub column: Option<LitStr>,
pub skip: Flag,
pub experimental_encode_as_json: Flag,
}Expand description
Available attributes on a column (struct field)
Fields§
§primary_key: Flag§insertable_primary_key: FlagMarks a primary key, but includes it in the Insertable struct.
default: FlagSpecifies that a default exists at the database level.
default_value: Option<NameValue<LitStr>>Specify a default value on the Rust side.
join_column: Option<NameValue<LitStr>>Note this column is not expected to exist on the model, but needs to exist in the database.
Example:
pub struct User {
#[ormlite(join_column = “organization_id”)]
pub organization: Join
many_to_many_table: Option<Ident>Example:
pub struct User {
pub org_id: i32,
#[ormlite(many_to_many_table_name = join_user_role)]
pub roles: Join<Vec
one_to_many_foreign_key: Option<Path>Example:
pub struct User {
pub id: i32,
#[ormlite(one_to_many_foreign_key = Post::author_id)]
pub posts: Join<Vec
pub struct Post { pub id: i32, pub author_id: i32, }
column: Option<LitStr>The name of the column in the database. Defaults to the field name.
skip: FlagSkip serializing this field to/from the database. Note the field must implement Default.
experimental_encode_as_json: FlagExperimental: Encode this field as JSON in the database.
Only applies to derive(IntoArguments). For Model structs, wrap the object in Json<..>.