remove some unneeded mutability

This commit is contained in:
Дамјан Георгиевски
2019-02-22 20:25:50 +01:00
parent aeb4b4c8a5
commit 473f8b8e31
5 changed files with 15 additions and 15 deletions

View File

@@ -43,11 +43,11 @@ use crate::error::MapResult;
/// Database methods
impl Collection {
pub fn save(&mut self, conn: &DbConn) -> EmptyResult {
pub fn save(&self, conn: &DbConn) -> EmptyResult {
self.update_users_revision(conn);
diesel::replace_into(collections::table)
.values(&*self)
.values(self)
.execute(&**conn)
.map_res("Error saving collection")
}

View File

@@ -213,7 +213,7 @@ use crate::error::MapResult;
/// Database methods
impl Organization {
pub fn save(&mut self, conn: &DbConn) -> EmptyResult {
pub fn save(&self, conn: &DbConn) -> EmptyResult {
UserOrganization::find_by_org(&self.uuid, conn)
.iter()
.for_each(|user_org| {
@@ -221,7 +221,7 @@ impl Organization {
});
diesel::replace_into(organizations::table)
.values(&*self)
.values(self)
.execute(&**conn)
.map_res("Error saving organization")
}
@@ -323,11 +323,11 @@ impl UserOrganization {
})
}
pub fn save(&mut self, conn: &DbConn) -> EmptyResult {
pub fn save(&self, conn: &DbConn) -> EmptyResult {
User::update_uuid_revision(&self.user_uuid, conn);
diesel::replace_into(users_organizations::table)
.values(&*self)
.values(self)
.execute(&**conn)
.map_res("Error adding user to organization")
}

View File

@@ -225,13 +225,13 @@ impl Invitation {
Self { email }
}
pub fn save(&mut self, conn: &DbConn) -> EmptyResult {
pub fn save(&self, conn: &DbConn) -> EmptyResult {
if self.email.trim().is_empty() {
err!("Invitation email can't be empty")
}
diesel::replace_into(invitations::table)
.values(&*self)
.values(self)
.execute(&**conn)
.map_res("Error saving invitation")
}