datastar
datastar copied to clipboard
Using counter datatype
How can we use the module to increment a counter field on a Model.update
?
@knation Sorry for the late response! We currently don't have specific support around the counter field but definitely open to ideas! We could add something specific for a counter field in here but I'm curious what your thoughts are for the API
@jcrugzz I think it could be a basic int value. So: Table.update({ id: '...', counterField: 1 });
would translate to counterField = counterField + 1
while Table.update({ id: '...', counterField: -3 });
would translate to counterField = counterField - 3
;
table.updatecounter as a syntax option is a good alternative. It helps remind coders that the only thing updateable in a counter table is the counter.