mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add retrieve all item_id for each field assosiated to a notes
This commit is contained in:
parent
5657b04d50
commit
4e878b14cc
@ -975,6 +975,9 @@ class DB:
|
||||
def notes_data_for(self, field_name, item_id):
|
||||
return self.notes.get_note_data(self.conn, field_name, item_id)
|
||||
|
||||
def get_notes_id_map(self):
|
||||
return self.notes.get_note_id_map(self.conn)
|
||||
|
||||
def set_notes_for(self, field, item_id, doc: str, searchable_text: str, resource_hashes, remove_unused_resources) -> int:
|
||||
id_val = self.tables[field].id_map[item_id]
|
||||
note_id = self.notes.set_note(self.conn, field, item_id, id_val, doc, resource_hashes, searchable_text)
|
||||
|
@ -686,6 +686,10 @@ class Cache:
|
||||
' Return all notes data as a dict or None if note does not exist '
|
||||
return self.backend.notes_data_for(field, item_id)
|
||||
|
||||
def get_notes_id_map(self) -> dict:
|
||||
' Return all item_id for each field assosiated to a notes. '
|
||||
return self.backend.get_notes_id_map()
|
||||
|
||||
@read_api
|
||||
def field_supports_notes(self, field) -> bool:
|
||||
' Return True iff the specified field supports notes '
|
||||
|
@ -269,6 +269,14 @@ class Notes:
|
||||
'resource_hashes': frozenset(self.resources_used_by(conn, note_id)),
|
||||
}
|
||||
|
||||
def get_note_id_map(self, conn):
|
||||
rslt = {}
|
||||
for (note_id, field_name) in conn.execute('SELECT id,colname FROM notes_db.notes'):
|
||||
if field_name not in rslt:
|
||||
rslt[field_name] = []
|
||||
rslt[field_name].append(note_id)
|
||||
return rslt
|
||||
|
||||
def rename_note(self, conn, field_name, old_item_id, new_item_id, new_item_value):
|
||||
note_id = self.note_id_for(conn, field_name, old_item_id)
|
||||
if note_id is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user