datastar icon indicating copy to clipboard operation
datastar copied to clipboard

Using counter datatype

Open knation opened this issue 8 years ago • 3 comments

How can we use the module to increment a counter field on a Model.update?

knation avatar Sep 28 '16 21:09 knation

@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 avatar Oct 11 '16 16:10 jcrugzz

@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;

knation avatar Oct 11 '16 18:10 knation

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.

michaelrempel avatar Oct 21 '16 19:10 michaelrempel