name delete if 0 attributions
This commit is contained in:
@@ -171,6 +171,16 @@ impl Name {
|
||||
})?
|
||||
.collect::<Result<Vec<Name>, _>>()?)
|
||||
}
|
||||
pub fn times_attributed(&self, conn: &Connection) -> Result<i64, PersonError> {
|
||||
Ok(conn
|
||||
.prepare("SELECT COUNT(*) FROM lines WHERE name_id = ?1")?
|
||||
.query_row((&self.id,), |r| r.get(0))?)
|
||||
}
|
||||
pub fn delete(self, conn: &Connection) -> Result<(), PersonError> {
|
||||
conn.prepare("DELETE FROM names WHERE id = ?1")?
|
||||
.execute((&self.id,))?;
|
||||
Ok(())
|
||||
}
|
||||
pub fn set_primary(&mut self, conn: &Connection) -> Result<(), PersonError> {
|
||||
if self.is_primary {
|
||||
return Err(PersonError::AlreadyPrimary);
|
||||
|
||||
Reference in New Issue
Block a user