class TinyDBBetterTable(Table):
This class is an add-on to TinyDB's Table class. It removes some computations that are not necessary in ACME.
- Document ID's are always strings.
- Since document ID's are strings, the conversion during each update is not necessary anymore.
| Class Method | assign |
Class method to assign this class to an existing Table instance. |
| Method | _get |
Return the ID for a newly inserted document. This method overloads the original method to return the ID as a string. |
| Method | _update |
Perform a table update operation. |
Class method to assign this class to an existing Table instance.
| Parameters | |
| self | Undocumented |
table:Table | A TinyDB Table instance. |
Return the ID for a newly inserted document. This method overloads the original method to return the ID as a string.
| Returns | |
str | The ID for the new document. |
Perform a table update operation.
The storage interface used by TinyDB only allows to read/write the complete database data, but not modifying only portions of it. Thus, to only update portions of the table data, we first perform a read operation, perform the update on the table data and then write the updated data back to the storage.
As a further optimization, we don't convert the documents into the document class, as the table data will not be returned to the user.