Delete message

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.123.73