I'm trying to add ORM to existsing structures:
#[derive(Debug, Queryable, Selectable)]
#[diesel(table_name = crate::schema::tokens)]
pub struct Token {
pub public_key: String,
pub name: Option<String>,
cannot find type `name` in module `crate::schema::tokens`
not found in `crate::schema::tokens`
Which macros to add above struct's field to ignore it for db manipulations?
You cannot.
Deriving Queryable
creates an implementation that will expect a Option<String>
equivalent to be returned from the database when loading as this type. And Selectable
creates an implementation to be used in SELECT ...
clauses and will ask for a name
. There are no attributes to ignore fields on these derive macros.
Frankly, this is not how Diesel is expected to be used. The types should map exactly to what your database has and its queries do. If you have different concepts for your business logic vs what is persisted, you should use different types and implement the appropriate conversions yourself.