pub struct ModelAttributes {
pub table: Option<LitStr>,
pub insertable: Option<Ident>,
pub database: Option<LitStr>,
}
Expand description
Available attributes on a struct
Fields§
§table: Option<LitStr>
The name of the table in the database. Defaults to the struct name. Example: #[ormlitex(table_name = “users”)] pub struct User { pub id: i32, }
insertable: Option<Ident>
The struct name of an insertion struct. Example: #[ormlitex(insertable = InsertUser)] pub struct User { pub id: i32, }
database: Option<LitStr>
Set the target database. Only needed if you have multiple databases enabled.
If you have a single database enabled, you don’t need to set this.
Even with multiple databases, you can skip this by setting a default database with the default-<db>
feature.
Currently, because methods conflict, you
You can use this attribute multiple times to set multiple databases.
Example:
#[ormlitex(database = “postgres”)]
#[ormlitex(database = “sqlite”)]
pub struct User {
pub id: i32,
}
This will generate orm code for User
for both the postgres
and sqlite
databases.