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.

Question - Does TypeORM provide feature to do atomic increment with int field?

See original GitHub issue

The shorthand of sql:

UPDATE table SET field = field + 1 WHERE id = :id;

Has there an API like

async increment(field:string,step:number=1);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

33reactions
pleerockcommented, Mar 28, 2018

Was implemented in #1845 and is available in latest @next. Example:

       // increment counter of post 1
       await connection
           .getRepository(Post)
           .increment({ id: 1 }, "counter", 1);

        // decrement counter of post 2
        await connection
            .manager
            .decrement(Post, { id: 2 }, "counter", 2);
9reactions
pleerockcommented, Oct 24, 2017

We’ll need to implement this new feature. But first we need a design proposal on what other methods we also need (like increment, decrement, sum, etc.) - all common operations we’ll need and create a separate type of query builder where those operations will be possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create autoincrement integer field in TypeORM ...
I design a table and want an integer autoincrement ...
Read more >
db.collection.findOneAndUpdate() — MongoDB Manual
Starting in MongoDB 4.2, the operation returns an error if the query field is not a document. If no document matches the filter...
Read more >
Announcing Vendure v0.16.0
Transactions are a database feature which enable atomic operations which means that a series of database operations are guaranteed to either all ...
Read more >
Transactions - Prisma
Atomic : Ensures that either all or none operations of the transactions succeed. The transaction is either committed successfully or aborted and rolled...
Read more >
Transactions and Concurrency - ORM - Doctrine
The first approach is to use the implicit transaction handling provided by ... to include custom DBAL operations in a unit of work...
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