User bio
404 bio not found
Member since Mar 2, 2016
Posts:
Warlin has not published any posts yet.
Replies:

Hi Omer, would your solution consider a trigger? Haven't tried this but you could have a trigger that executes after insert/update that would launch an update on the affected row that basically would "add" the new value in the counter to the old one:

Your queries should change to something like this 

INSERT OR UPDATE myTable SET name='Omer', counter = 1

INSERT OR UPDATE myTable SET name='Omer', counter = -1

.....

The logic in the trigger would grab old value (handle NULL as 0) and add the new value only in cases where both are different or whatever your business logic might be.

To prevent infinite loops on updates your after update trigger can be defined to only be executed after any of the other columns in the table are updated with the exception of counter.

$LISTBUILD (IDs of referenced objects) should do the trick. The "parent" table here is only storing the corresponding IDs not the entire objects. You need to save each object individually and then link them.

While the object counterpart takes care of saving/inserting both objects in memory, the same is not true for SQL. You need to treat each object as individual rows on different tables.

Certifications & Credly badges:
Warlin has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Warlin has no followers yet.
Following:
Warlin has not followed anybody yet.