scripting: setting attributes: make op "update" work like "add" if not existing

Started by ubacher, July 15, 2017, 03:47:47 PM

Previous topic - Next topic

ubacher

When writing an attribute to a file one has to read the attribute first in order to decide if one has to use
the op: 'add' or the op: 'update'.

Making the op: 'update' work like 'add' when an attribute does not exist would simplify code a lot.
(saves one additional async call per setting)

Mario

update exists to update an existing instance. You need to provide the instance if to update, which means you need to determine it in advance. And if you cannot determine the instance id in advance, there is no need (or way) to call update. Just call add when you want to add a new record.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

I only allow one instance. Thus I want to update (or add) instance
  • .
    I have to read the attribute just to see if it exists --> use update
    else I need to use add. Because of the async nature this extra call is inconvenient.

    I assume having just one instance of a (file)  attribute would be very common.

Mario

I don't make assumptions usually about what is common or not.
It is easy and fast to determine if and how many Attribute records a file has and then whether to update existing records or add new ones.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook