Skip to main content

Can I replace this


model.updateRow(row, {UpVotes: row.UpVotes + 1});


with this


row.UpVotes++


??

Does that accomplish the same thing?

No, they do not do the same thing. Your first way is the correct way. The second way, row.UpVotes++ introduces a “side effect”. It is actually setting the property row.UpVotes as one greater than the current value of row.UpVotes. You don’t want to do this because this would mean you’re going around the Skuid API, and directly modifying a property on a model. Then, after that, you are using the Skuid API, which is kind of silly.


To be clear, my comment was contrasting these two options.


model.updateRow(row, {UpVotes: row.UpVotes + 1});


and


model.updateRow(row, {UpVotes: row.UpVotes++ });

If you’re contrasting


model.updateRow(row, {UpVotes: row.UpVotes + 1});


and


row.UpVotes++


Then the answer is the same, but for different reasons. The first way is correct, and the second way is wrong. Skuid’s implementation of updateRow is hundreds of lines of Javascript that take care of many, many things. Just directly modifying model properties will get you into trouble, fast. 🙂


This was the version I intended to contrast. Thanks.