Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Alessandro Tagliapietra

    seems that

      @ManyToOne(type => Invoice, invoice => invoice.lines, {
        primary: true
      invoice: Invoice;
        primary: true
      orderLineNum: number;

    is the way to go

    Hi, i go a problem with migrations, when one or more migration are already applied on the database, typeorm can't find the changes between the code and the live version of the database. That return me the message : "No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command"
    I can generate the first migration without any problem. But i can't for the next migrations
    If someone already know this bug / how to fix it. That can help me a lot. Thank's
    Tomasz Gałkowski
    @remibruyere I know this won't be much help, but we gave up on TypeORMs migrations. My advice is (it saved us a lot of headaches): disable autosync and write migrations by hand (create empty migration via typeorm CLI). :(
    I hate to be that guy but could we get some action on these issues?

    Hi, I'm using this old sql.js v0.5.0 and don't understand how to change the conection in order to upgrade to 1.0

    I'm using the Ionic implementation.

    let dbOptions: ConnectionOptions;
     dbOptions = {
              type: 'sqljs',
              location: 'browser',
              autoSave: true
     Object.assign(dbOptions, {
          synchronize: true,
          autoSchemaSync: true,
          migrationsRun: true,
          entities: [    tables   ]
         return createConnection(dbOptions).then(connection => {
          console.log("Data Access connected!");
          return connection;
        }).catch(error => {
          //console.log("Data Access Error : ", );
          return null;
    Sam Grönblom

    Does this work in typeorm?

    class Foo {
      @PrimaryGeneratedColumn() id: number
      nestedProp: {
        @Column() greeting: string

    Basically setting a nested property.

    Sam Grönblom

    Hey, I'm trying out migrations:generate on an empty DB with postgres. For some reason the generated migration is doing the following:

    • Create the table as expected based on a single @Entity I have defined
    • Drop all the columns of the previously created table
    • Recreate all the columns that it just deleted

    This seems buggy to me.

    Sam Grönblom
    Seems like there are a lot of issues on GH related to migrations:generate
    Is this channel kind of dead or?
    Jemli Fathi

    hello guys
    I am facing a tough day due to FindConditions/FindManyOptions in Repository.find method.
    most of the worst, I've got this error :

    [Nest] 26433 - 2019-09-06 12:37:02 [ExceptionsHandler] Maximum call stack size exceeded +3373ms
    RangeError: Maximum call stack size exceeded
    at String.split (<anonymous>)
    at Function.QueryBuilderUtils.isAliasProperty (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/QueryBuilderUtils.ts:17:15)
    at JoinAttribute.getValue (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/JoinAttribute.ts:143:40)
    at JoinAttribute.get [as relation] (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/JoinAttribute.ts:162:53)
    at JoinAttribute.get [as metadata] (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/JoinAttribute.ts:175:18)
    at SelectQueryBuilder.join (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/SelectQueryBuilder.ts:1299:27)
    at SelectQueryBuilder.leftJoin (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/SelectQueryBuilder.ts:284:14)
    at SelectQueryBuilder.leftJoinAndSelect (/home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/query-builder/SelectQueryBuilder.ts:364:14)
    at /home/fethijemli/Documents/dev/node/nest/CIO-FORUM-BACKEND/src/find-options/FindOptionsUtils.ts:246:16
    at Array.forEach (<anonymous>)

    Salvatore Iovene
    Hello. I can't seem to inject anything in an EventSubscriber. Whatever I try to inject, is undefined. What might be wrong?
    Salvatore Iovene
    Here is some of the relevant code: http://dpaste.com/335CT48
    Deyve Vieira


    Can I use migrations with synchronized database is true?

    Sam Grönblom
    Can you specify the order of columns in a composite primary key?
    Sam Grönblom
    I think I am running into this bug: typeorm/typeorm#1668 which part of the code should I look at to see why the quotation is missing?
    Ey there! I have one question related with a best practice of adapting TypeORM to a microservice stack. I have several microservices developed in typescript, each one of them using typeGraphQL with different queries and mutation to different models. I'm wondering if there is a way to dynamically use TypeORM (i.e singleton pattern in an adapter common library) and define entities in a different place that the adapter is defined.
    So a new microservice added should ask for the entities it needs. I've taken a look to the custom repositories and separate entity definition, but I need some light on this.
    I've got 2 entities, Account and Item, after creating an Account, an Item needs to be created too. I'm thinking of doing this in AfterInsert, but if the Item creation fails, I want the Account to be deleted from the database, as if it were all in one transaction, anyone got any ideas?
    Sam Grönblom
    Aren't you describing a simple transaction?
    Jorgen V
    Can I ask for help here, or is this channel for development of TypeORM?
    Sam Grönblom
    You can try both, no guarantees either will work :)
    Saulo S. Toledo
    Hi guys. I am using Webpack in a project with TypeORM and I am having an issue with RepositoryNotFoundError. The connection is created by an internal code I should not change, so I was trying to use ormconfig.js to solve the issue. Do you have a suggestion of an approach to make that work automatically? I already separated the bundles in Webpack, each entity is transpiled to a separated js file.
    Saulo S. Toledo
    Hi all. Is there an official way to get the table prefix in a migration file?
    I have queries like "ALTER TABLE 'table_name'...", but I would like to load the table prefix from there.
    or the table name directly from the entity...
    Juliano Lazzarotto
    Is it possible, using Repository, to select for update (table X), insert (table Y) ? Any example around
    hi, guys, is there a built-in mechanism to populate entity from Json like new User().fromJson(data)
    Juliano Lazzarotto
    Is it possible to use @Query( type ---> using a ViewEntity????)
    I keep receiving an error GraphQL cannot determine the output type - Dunno if the ViewEntity works as Entity
    NVM --- I forgot the annotations :D my bad
    Juliano Lazzarotto
    findAndCount and Count are supposed to work with MySQL? I'm receiving an error -> SELECT COUNT(DISTINCT()) FROM ....
    was this a dumb question or there are no active users to answer it? "hi, guys, is there a built-in mechanism to populate entity from Json like new User().fromJson(data)"
    Iv Po
    Hi, any one knows why @BeforeUpdate() decorator/subscriber event dont work with mongodb? I cannot find code related to this in MongoQueryRunner, seems like its just calls methods from mongo driver without using Broadcaster or something like UpdateQueryBuilder does. I am trying to use repository methods replaceOne(), update(), when i use save() for new Entity @BeforeInsert() event is triggered, but update events are not. I know that mongodb is experimental, but is it okay or i am doing something wrong?)
    @dan-conachi as far as I know there no such method
    I'am inserting multiple related entities to a postgres db. In the logs I see multiple transaction being started even though I don't start a transaction myself.
    I assume that typeorm automatically starts transaction in certain cases so it can rollback however is this somewhere documented on what behvaiour I can expect?
    thank @warreee I found and use now on the entity static toClass(data: Object) { return plainToClass(Class, data, { excludeExtraneousValues: true }) }
    Shaishav Pidadi
    Hey, How can I add and remove specific elements from the array field in typeORM Postgres?
    Cihan Bebek

    Hi! I'm facing an issue with typeorm that I'm having trouble solving:

    I have a entity

    class MyEntity implements MyEntityInterface {
      @PrimaryColumn({ type: 'int' })
      public id: number;
      @Column({ type: 'varchar' })
      public message: string;

    now when I do a queryBuilder and a getMany(), I would like to have this new field in the result which is aggregated from other database tables


           // query builder for myEntity
            .addSelect(`EXISTS (
              SELECT true
              FROM other_table`, 'myAggregateField'

    how can I include the myAggregateField in the result?

    atm typeorm does some magic and cant build the MyEntity-object with the myAggregateField value in it
    I tried simply adding public myAggregateField?: boolean; to the MyEntity-class, but it didnt help
    Vinícius do Carmo
    Hi you all! What is the safer method to get the old values of my entity in my afterUpdate inside my Surbscriber class? thanks
    Bhuvin Thakker
    Hi guys,
    I am using Typeorm with Postgres.
    My Problem is:
    I have a column with timestamp type, which has a default value as now.
    I intend to use this column as a cursor for Paging i.e. GreaterThan the maximum date of the Last page.
    But here there is a problem that there is happening a difference of milliseconds happening when I read.
    For e.g.:
    In DB: 2019-12-18 16:10:20.659202+01
    When read through TypeOrm: 2019-12-18T16:10:20.659Z
    Can you please help me?
    I'm farcing this issue :UnhandledPromiseRejectionWarning: QueryFailedError: ER_LOCK_DEADLOCK: Deadlock found when trying to get lock; try restarting transaction
    Any help ?
    Taras Kucyj
    @Index({ fulltext: true }) @Column({type: 'tsvector'}) descriptionTsVector: string;
    Where i can read more about use fulltext and tsvector?
    1 reply
    inset update and select data
    Lev Kuznetsov

    I'm getting an error in a browser app bundled using web pack with sql.js@1.1.0:

    TypeError: Cannot read property 'Database' of undefined
          at SqljsDriver.eval (webpack:///./node_modules/typeorm/browser/driver/sqljs/SqljsDriver.js?:278:62)
          at step (webpack:///./node_modules/tslib/tslib.es6.js?:120:23)
          at Object.eval [as next] (webpack:///./node_modules/tslib/tslib.es6.js?:101:53)
          at eval (webpack:///./node_modules/tslib/tslib.es6.js?:94:71)
          at new Promise (<anonymous>)
          at Module.__awaiter (webpack:///./node_modules/tslib/tslib.es6.js?:90:12)
          at SqljsDriver.createDatabaseConnectionWithImport (webpack:///./node_modules/typeorm/browser/driver/sqljs/SqljsDriver.js?:272:63)
          at SqljsDriver.eval (webpack:///./node_modules/typeorm/browser/driver/sqljs/SqljsDriver.js?:137:56)
          at step (webpack:///./node_modules/tslib/tslib.es6.js?:120:23)
          at Object.eval [as next] (webpack:///./node_modules/tslib/tslib.es6.js?:101:53)

    it looks like it's inside SqljsDriver.prototype.createDatabaseConnectionWithImport = function (database) at line isLegacyVersion = typeof this.sqlite.Database === "function";, downgrading to sql.js@0.5.0 solves that