How to do this update statement

32 views
Skip to first unread message

Boris Matos Morillo

unread,
May 22, 2015, 7:30:34 PM5/22/15
to sequ...@googlegroups.com
Hi, is there anyway to do this?:

START TRANSACTION;
UPDATE images SET counter=counter+1 WHERE image_id=some_parameter;
COMMIT;

maybe?:

MyModel.update({
 $inc: {
   counter: 1
 }
});

Jan Aagaard Meier

unread,
May 28, 2015, 4:16:07 AM5/28/15
to sequ...@googlegroups.com
You can load the instance (`Images.find`) and call increment on the instance http://docs.sequelizejs.com/en/latest/api/instance/#incrementfields-options-promisethis
Reply all
Reply to author
Forward
0 new messages