diff --git a/rslib/src/storage/note/get_without_fields.sql b/rslib/src/storage/note/get_without_fields.sql new file mode 100644 index 000000000..61fe1702c --- /dev/null +++ b/rslib/src/storage/note/get_without_fields.sql @@ -0,0 +1,10 @@ +SELECT id, + guid, + mid, + mod, + usn, + tags, + "", + cast(sfld AS text), + csum +FROM notes \ No newline at end of file diff --git a/rslib/src/storage/note/mod.rs b/rslib/src/storage/note/mod.rs index d8a28b630..5d6e680b5 100644 --- a/rslib/src/storage/note/mod.rs +++ b/rslib/src/storage/note/mod.rs @@ -29,6 +29,17 @@ impl super::SqliteStorage { .transpose() } + pub fn get_note_without_fields(&self, nid: NoteID) -> Result> { + self.db + .prepare_cached(concat!( + include_str!("get_without_fields.sql"), + " where id = ?" + ))? + .query_and_then(params![nid], row_to_note)? + .next() + .transpose() + } + /// If fields have been modified, caller must call note.prepare_for_update() prior to calling this. pub(crate) fn update_note(&self, note: &Note) -> Result<()> { assert!(note.id.0 != 0);