On_conflict

I’m working on my object serialization database.

It annoyed me having to define an update method.. until I found another way:

By setting a constraint on name (unique), the insert will trigger a conflict. I can then resolve the conflict via an update.

INSERT OR IGNORE INTO Table(name, obj)
VALUES( some_key, some_serialized_object )
ON CONFLICT(name) DO UPDATE SET
 obj = the_serialized_object
WHERE name = some_key;

Now my module only has two methods again: ‘sto’ and ‘rec’.. and ‘sto’ s both insert and update.