mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Add get_note_without_fields() from storage
This commit is contained in:
parent
f7e4b6d822
commit
1823c0dda4
2 changed files with 21 additions and 0 deletions
10
rslib/src/storage/note/get_without_fields.sql
Normal file
10
rslib/src/storage/note/get_without_fields.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
SELECT id,
|
||||||
|
guid,
|
||||||
|
mid,
|
||||||
|
mod,
|
||||||
|
usn,
|
||||||
|
tags,
|
||||||
|
"",
|
||||||
|
cast(sfld AS text),
|
||||||
|
csum
|
||||||
|
FROM notes
|
|
@ -29,6 +29,17 @@ impl super::SqliteStorage {
|
||||||
.transpose()
|
.transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_note_without_fields(&self, nid: NoteID) -> Result<Option<Note>> {
|
||||||
|
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.
|
/// 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<()> {
|
pub(crate) fn update_note(&self, note: &Note) -> Result<()> {
|
||||||
assert!(note.id.0 != 0);
|
assert!(note.id.0 != 0);
|
||||||
|
|
Loading…
Reference in a new issue