Quote:
Originally Posted by kiwidude
I see Kovid has merged the changes now so I shall have an experiment later.
|
Note the slight API change that the code I posted didn't use, but should. I changed the add_multiple method to have a parameter that tells it to delete all existing data for that name before adding the new data.
Code:
add_multiple_custom_book_data(self, name, vals, delete_first=False):
Also note that 'vals' must be an iterable that has a book_id as a key/index and the object to be serialized as the data. Either a list or a dict will work. In my test I used a dict.
The get_all_custom_book_data method does what you would expect.
For completeness I also added delete_all_custom_book_data(self, name). It removes all records with 'name', regardless of book_id.