ABG
18
Further thought ...
I see in your work a problem similar to another users' work that I saw within the last day or so.
He had two versions of the truth, a global variable and a TinyDB value.
They were causing confusion.
I advised getting rid of the global variable, and using only the TinyDB value.
Here is a sample app that uses TinyDB without any global variables ...