From 613ac26d0e70bc71f591f3d4caff75fddd6d6ed1 Mon Sep 17 00:00:00 2001 From: dror-heller Date: Wed, 5 May 2021 12:44:26 +0300 Subject: [PATCH 1/2] Add documentation for increment utility method --- docs/manual/core-concepts/model-querying-basics.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/manual/core-concepts/model-querying-basics.md b/docs/manual/core-concepts/model-querying-basics.md index 42e89792fbe3..ee37fcaccf26 100644 --- a/docs/manual/core-concepts/model-querying-basics.md +++ b/docs/manual/core-concepts/model-querying-basics.md @@ -699,3 +699,12 @@ await User.min('age', { where: { age: { [Op.gt]: 5 } } }); // 10 await User.sum('age'); // 55 await User.sum('age', { where: { age: { [Op.gt]: 5 } } }); // 50 ``` + +### `increment`, `decrement` + +Sequelize also provides the `increment` convenience method. + +Let's assume we have a user, whose age is 10. + +User.increment({age: 5}, { where: { id: 1 } }) // Will increase age to 15 +User.increment({age: -5}, { where: { id: 1 } }) // Will decrease age to 5 From 0b871f87e01594f09cf1bfe7c76ade061bb81af7 Mon Sep 17 00:00:00 2001 From: drorh Date: Wed, 5 May 2021 13:42:02 +0300 Subject: [PATCH 2/2] Edit docs --- docs/manual/core-concepts/model-querying-basics.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/manual/core-concepts/model-querying-basics.md b/docs/manual/core-concepts/model-querying-basics.md index ee37fcaccf26..00298177b848 100644 --- a/docs/manual/core-concepts/model-querying-basics.md +++ b/docs/manual/core-concepts/model-querying-basics.md @@ -706,5 +706,7 @@ Sequelize also provides the `increment` convenience method. Let's assume we have a user, whose age is 10. -User.increment({age: 5}, { where: { id: 1 } }) // Will increase age to 15 -User.increment({age: -5}, { where: { id: 1 } }) // Will decrease age to 5 +```js +await User.increment({age: 5}, { where: { id: 1 } }) // Will increase age to 15 +await User.increment({age: -5}, { where: { id: 1 } }) // Will decrease age to 5 +```