note type removal
This commit is contained in:
parent
d32935382d
commit
a181d9aa02
@ -960,9 +960,8 @@ impl Backend {
|
||||
})
|
||||
}
|
||||
|
||||
fn remove_notetype(&self, _id: i64) -> Result<()> {
|
||||
println!("fixme: remove notetype");
|
||||
Ok(())
|
||||
fn remove_notetype(&self, id: i64) -> Result<()> {
|
||||
self.with_col(|col| col.remove_notetype(NoteTypeID(id)))
|
||||
}
|
||||
|
||||
fn new_note(&self, ntid: i64) -> Result<pb::Note> {
|
||||
|
@ -375,4 +375,13 @@ impl Collection {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn remove_notetype(&mut self, ntid: NoteTypeID) -> Result<()> {
|
||||
// fixme: currently the storage layer is taking care of removing the notes and cards,
|
||||
// but we need to do it in this layer in the future for undo handling
|
||||
self.transact(None, |col| {
|
||||
col.storage.set_schema_modified()?;
|
||||
col.storage.remove_notetype(ntid)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,26 @@ impl SqliteStorage {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn remove_notetype(&self, ntid: NoteTypeID) -> Result<()> {
|
||||
self.db
|
||||
.prepare_cached("delete from cards where nid in (select id from notes where mid=?)")?
|
||||
.execute(&[ntid])?;
|
||||
self.db
|
||||
.prepare_cached("delete from notes where mid=?")?
|
||||
.execute(&[ntid])?;
|
||||
self.db
|
||||
.prepare_cached("delete from templates where ntid=?")?
|
||||
.execute(&[ntid])?;
|
||||
self.db
|
||||
.prepare_cached("delete from fields where ntid=?")?
|
||||
.execute(&[ntid])?;
|
||||
self.db
|
||||
.prepare_cached("delete from notetypes where id=?")?
|
||||
.execute(&[ntid])?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn move_cards_for_repositioned_templates(
|
||||
&self,
|
||||
ntid: NoteTypeID,
|
||||
|
Loading…
Reference in New Issue
Block a user