Skip to content

How to update and increment? #7268

@novoxd

Description

@novoxd

I do:

return models.myModel.findById(model_id).then(my_model => {
  return my_model.decrement(['some_field'], { by: 2 })
});

I get:

SELECT "id", "some_fild" FROM "myModel" AS "myModel" WHERE "myModel"."id" = '1';
UPDATE "myModel" SET "some_fild"="some_fild" + -2 WHERE "id" = '1' RETURNING *

I want: (only update query)

UPDATE "myModel" SET "some_fild"="some_fild" + -2 WHERE "id" = '1' RETURNING *

How can I do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions