Fixing exporting and clearing my TinyDB data

The way to approach this depends on how you are using NameSpaces to separate records by day.

Go back and reread your code to see how you are using NameSpaces, and tell us how they are used.

Oh, thanks Taifun, ...I forgot to mention that I don't use extensions :slight_smile:
However thanks for the information that the sharing component is not able to do it. So I will find some other solution.

Namespace is set to "call Clock: Now" in the format "yyyyMMdd" and each time I save a tag it is associated with that day's Namespace. And I have to set the Namespace every time I recall the tags of the day.

So if there is no way to retrieve the name of the Namespace, every time I save I could append this tag to the File, as you mentioned? ...but what is the best way to do it in my case?

...but I'm also thinking ...I can't append to File, because the user may have deleted a tag from the table, but it will remain in the File. So another solution is needed.

I just would like to recall all tags, then I will think how to write the day date.

Since the NameSpace values are just dates YYYYMMDD, the Clock component has blocks that can be used to jump forward and backwards in time to generate YYYYMMDD values for all dates in whatever date range you want.

That's why i suggested a From and To Date Picker as one alternative for requesting a range of dates.

Alternatively, you could make a List Picker with options

  • Last Week
  • Last Month
  • Forever

to generate sequences of dates stretching over recent history.

This is a matter of personal taste, and I would not impose such a choice on you.

The File need not be persistent. Since the persistent data is already in the TinyDB NameSpaces, it is cleaner to generate the File contents fresh at each export time, with just the requested range of dates' data.

Things to study:

  • Control blocks for iteration
  • Clock blocks for millisecond conversion
  • Clock blocks for date conversion and addition.

Could I set date pickers FromDate: January 2022 ToDate: Clock-Now so that automatically when "Export Database" is clicked all the Namespaces (till Now) are called without making the user choose? ...could you show me the blocks?

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

See A way to group projects by theme - #10 by ABG
for a demo.

Because your Blocks Workspace is so bloated I had to work in a separate Screen.
It should be no problem for you to correct component names to match what you have.

Great, it works, ...thanks
The "NameSpaces" variable is necessary? ...I don't see it used in blocks.


Before moving on to data cleaning, I have a question:
In August I reinstalled companion and the data was deleted, but only for August, the data from other months remained on TinyDB.
How does it work?

Right, I missed that.
Glad to see you're reading the code.
It's left over from when I was torn between two different ways of iterating over the different NameSpaces:

  • generating all of them first in a list, then looping over the list, or
  • using one of the loop forms (Do While) involving incrementing a value in a range
    I ended up choosing the second approach, and forgot I had left a remnant of the first approach.
    You can remove that using the blue button and the keyboard delete key. Beware of things popping out of their sockets when you do that.

The storage for the Companion is a garbage can shared across all the apps that have been tested on the Companion. No one cleans it out.

I thought I had developed a little app to browse all the different File scopes available to an app, but I can't find it.

The reinstall residue remains a mystery to me.

I assembled these blocks to clear Day Data and they work.
...for me it is always a nice surprise when something works :slight_smile:

Are they ok? ...or is there any block to improve?

I also assembled the blocks to clear All Data from TinyDB, are they okay? it enough to use just "ClearAll" block?
(other blocks under "ClearAll" are for reloading the table)

How can I test them before clicking the "Clear Data" button?
...once the data is deleted there will be nothing to test :slight_smile:

is a new notifier required for each notification?

Yes, it is equivalent to looping over all the tags in the current NameSpace and clearing each tag.

Depends on what you mean by "All Data".

All data in one day, or all data from 2022 to current day?

Running an export is a good way to test how well your clearing operation worked.

Only for cases where you need to respond differently to the Okay or Cancel choices, using the matching Event block to handle just that decision.

Are you saying that to clear the selected day's data it is sufficient to set Namespace and to add the "ClearAll" block? this?

...and to delete the data of the whole TinyDB is the "ClearAll" block sufficient? this?
Schermata 2022-09-16 alle 12.13.26

I meant, how can I check what data is going to be cleared by my blocks before clicking the button? ...not after clicking.

I did not understand this, ...can you show the blocks?

Exactly, assuming the global Date contains the selected date.

Clarify what you mean by the whole TinyDB.
Do you have the false belief that the TinyDB component remembers what values it had used for its NameSpace when saving data in different NameSpaces?

No, it doesn't.

I recommend reading the blocks that export all the different NameSpaces' data, to see how a loop over time is necessary for what you might be asking.

This requires a sample app, which requires a separate post, hopefully to follow.

So if I had only stored the tags in the TinyDB, then the "ClearAll" block would be enough to clear all data.
But having grouped my tags into Namespaces, I have to indicate all Namespaces where there are the tags to be cleared.
Is it correct?
These are the right blocks?:

Yes, you got it!

As promised, here is a sample app which demonstrates the two styles of Notifier use:

  • Single Notifier reused for multiple questions
  • Multiple Notifiers in the Designer, one question each.

The sample app is a dialog asking whether or not to launch World War 3.
(VaultTec is an underground bunker maker from the Bethesda Softworks' Fallout(TM) series)

Notifier_demo.aia (9.8 KB)

Multiple Notifier components in the Designer, with individual events:

Single Notifier reused in an if/then/elseif ladder:

Choosing between these styles is a matter of personal taste.
The Single Designer approach forces the coder to be very explicit in his choice texts, which is a good thing.

Thanks a lot, will probably be useful to me later.
In this case I only have two notifiers, so since it doesn't change much, I let these two components.

How do I start a new line in the notifier message text? ..."\n" doesn't work.


I created the buttons to delete the single tags (rows in table).
It works, but now I realized that it only deletes once. If, after clearing one tag, I select another tag, it doesn't delete it anymore. I have to reload the page to be able to delete another tag.

This is the sequence:

I've already checked and can't find the error, can you help me to understand what is wrong?

I don't understand your persistent failure to set NameSpace before using TinyDB1.

I am also unable to diagnose missing procedures.

I tried to reverse the order (Namespace-TinyDB) but it created a chaos when loading the data.
Here is the file:
Nadi_13.aia (1002.9 KB)