From 1823c0dda4c71198ac3f711d586ee630b140220a Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 20 Mar 2021 11:59:45 +0100 Subject: [PATCH] Add get_note_without_fields() from storage --- rslib/src/storage/note/get_without_fields.sql | 10 ++++++++++ rslib/src/storage/note/mod.rs | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 rslib/src/storage/note/get_without_fields.sql 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);