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.

Property 'insert' does not exist on type 'QueryRunner' after upgrading

See original GitHub issue

Issue type:

[X] question [ ] bug report [ ] feature request [X] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [X] mysql / mariadb [ ] oracle [ ] postgres [ ] sqlite [ ] sqljs [ ] react-native

TypeORM version:

[X] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

export class FirstReleaseChanges1487003618914 implements MigrationInterface {

  async up(queryRunner: InsertQueryRunner): Promise<any> { // Next-gen Typeorm
    await queryRunner.insert('configuration', {
      name: 'defaultValues',
      value: JSON.stringify({
        // ... not important
      })
    });
  }
}

Upgraded from 0.1.21 to 0.2.5, and none of my migrations compile anymore. Error message described in issue title.

Searched through the CHANGELOG.md for signs of something which replaces this method, but could only find this:

insert, update and delete methods of QueryRunner now use InsertQueryRunner, UpdateQueryRunner and DeleteQueryRunner inside

The documentation for QueryRunner is marked as TBD, with no further instructions on how to retreive or use the InsertQueryBuilder. My VSCode does not know of any class called this and it does not seem to be exported anywhere in typeorm.

How can I translate the above code to something working under TypeOrm latest?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

27reactions
pleerockcommented, May 17, 2018

@npatterson you can insert into custom table as well:

queryRunner
   .manager
   .createQueryBuilder()
   .insert()
   .into("table_name")
   .values({ ... })
   .execute()
6reactions
pleerockcommented, May 5, 2018

queryRunner.manager BTW which provides EntityManager with createQueryBuilder and other things.

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript - TypeORM upsert - create if not exist - Stack Overflow
For anyone finding this in 2021, Typeorm's Repository.save() method will update or insert if it finds a match with a primary key.
Read more >
Working with Query Runner - typeorm - GitBook
Each new QueryRunner instance takes a single connection from connection pool, if RDBMS supports connection pooling. For databases not supporting connection ...
Read more >
RelationQueryBuilder - typeorm
QueryBuilder can be initialized from given Connection and QueryRunner ... Contains all properties of the QueryBuilder that needs to be build a final...
Read more >
EntityManager - typeorm
Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted. You can execute bulk...
Read more >
API with NestJS #67. Migrating to TypeORM 0.3
First, they got rid of the findOne() function returning the first row from the table when not provided with an argument. It was...
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