mikee47 / ConfigDB

Configuration database for Sming
GNU General Public License v3.0
3 stars 1 forks source link

Support resetting properties to their default values #46

Closed mikee47 closed 2 months ago

mikee47 commented 2 months ago

Objects and arrays can be reset (PR #37) but as per https://github.com/mikee47/ConfigDB/discussions/20#discussioncomment-10471624 there is currently no specific way to reset property values to their default. This PR adds resetXXXX() methods to generated updater code for this purpose.

Objects have a defined defaultData structure which contains the default values and can be useful for introspection. These could be used to reset default values, but the types do not always agree with those in the API and doing it this way is a bit clunky.

pljakobs commented 2 months ago

can I trigger the reset from the importFromStream? I was thinking about how to reset a property to default from the frontend.

mikee47 commented 2 months ago

Yes, set the property to null.

mikee47 commented 2 months ago

You'll have to read it back again to get the actual values of course.