January 2019
Intermediate to advanced
520 pages
14h 32m
English
The last model we need is Message, which relates to the records in the messages table:
#[derive(Debug, Identifiable, Queryable, Associations, Serialize, Deserialize)]#[belongs_to(Channel)]#[belongs_to(User)]#[table_name = "messages"]pub struct Message { pub id: Id, pub timestamp: NaiveDateTime, pub channel_id: Id, pub user_id: Id, pub text: String,}
This model also uses derived traits which we discussed in the first example. Now, we can implement our database interaction crate using the generated schema and the declared models.
Read now
Unlock full access