January 2019
Intermediate to advanced
520 pages
14h 32m
English
If you posted a message and decided to remove it, we need a method to delete messages from messages table. Look at delete_message method implementation:
pub fn delete_message(&self, message_id: Id) -> Result<(), Error> { diesel::delete(messages::table) .filter(messages::id.eq(message_id)) .execute(&self.conn)?; Ok(())}
This function uses the delete method, which returns a DeleteStatement instance, which has a filter method as well. We set a filter with the id column equal to the provided message_id and execute the generated DELETE SQL statement.
Read now
Unlock full access