question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I incr/decr a value?

See original GitHub issue

How can I increase a value by one in one step? Seems that updateById can not do this. Can I do that by using queryBuider? Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

127reactions
pleerockcommented, Jul 19, 2017

you simply load an object, increase its property and save object, e.g.

const post = await repository.findOneById(1);
post.counter++;
await repository.save(post);
89reactions
pleerockcommented, Mar 26, 2018

alternatively you can use QueryBuilder to run update query:

        await connection.createQueryBuilder()
            .update(User)
            .set({ counter: () => "counter + 1" })
            .execute();

See example here.

Or you can simply run sql query using connection.query method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Increase Your Value (211) - Life Skills That Matter
#1 Constantly Acquire New Skills · Acquire new skills on a regular basis. I would suggest creating an annual learning plan for new...
Read more >
5 Strategies That Increase Your Value And Lead To A ... - Forbes
Build your personal brand. Value is created when you've built social proof for yourself. · Never stop learning and adding new tools. ·...
Read more >
4 Ways to Increase Your Value and Earn a Pay Raise This Year
1. Restructure your daily performance to achieve a higher level of efficiency · 2. Master a new skill or knowledge area · 3....
Read more >
How to increase your value - Make Me Better
How to increase your value · 1. Have an opinion and stick to it · 2. Be active during group conversations · 3....
Read more >
Percentage Increase Calculator
Percent increase formula · Identify the original value and the new value. · Input the values into the formula. · Subtract the original...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found