Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Luisfermp
    @Luisfermp
    Hello there! I hope all of you are fine! I have a very simple question. When synchronize:false, a non existing model should be created?
    Francisco Palomares
    @FranciscoPalomares
    Hi, how to select dynamic schema bdd in entity on fly? Thanks
    Paul
    @stovberpv
    Hello. I apologize for my English, I use a translator. Can anyone suggest how to cast types in the builder.addOrderBy('plan.status::TEXT', 'ASC') order? The status is a JavaScript enum that is not sorted in the correct order, and when using orderBy postgresql sorts the entries according to the order in that enum. The problem is that when adding a cast to a field, the typeorm cannot complete the request. How can this be solved?
    JF
    @jsalamander
    Hei there :) I'm trying to disconnect the default connection at the end of a Jest test suite. Sadly the close() method on the default connection gets stuck. I'm using postgres, any ideas what could be wrong?
    Dogan1998
    @Dogan1998
    Hello, I have created a model with typeorm which contains a column with an enum. When i retrieve the metadata of the columns with getMetadata("") I only get the values of the fields and not the whole enum. Is there a way to retrieve the fields with their values?
    Yosh
    @yohannpoli

    Hi, is this possible to use a specific typescript enum column in two ChildEntity on the same property? it seems that the sql generated only uses the first child enum as column type, as example, what i want to do:

    
    @Entity()
    @TableInheritance({ column: { type: 'enum', enum: EventKind, name: 'kind' } })
    export abstract class Event {
      @PrimaryGeneratedColumn()
      id: number;
    
      @Column({
        type: 'enum',
        enum: EventKind,
      })
      protected kind: EventKind;
    }
    
    @ChildEntity(EventKind.FirstChild)
    export class FirstChild extends Event {
      @Column({ type: 'enum', enum: FirstChildType })
      type: FirstChildType; // should not be possible to set a SecondChildType there
    }
    
    
    @ChildEntity(EventKind.SecondChild)
    export class SecondChild extends Event {
      @Column({ type: 'enum', enum: SecondChildType })
      type: SecondChildType; // should not be possible to set a FirstChildType there
    }

    Is this possible? thanks in advance

    Seshachalam
    @malisetti
    hello, i have been using tyeporm with ormconfig.json
    my database is postgres 13
    i am able to access DBs using psql
    but typeorm is not able to createConnections
    and is failing with "Connection terminated due to connection timeout"
    i have double checked to see if i have proper connection options in ormconfig
    Piotrek98
    @Piotrek98
    Hi, i have a problem with typeorm databse
    thanks for any help, is important for me
    Michel
    @michel-fresh
    Hello! wondering if anyone knows how to use query builder to sort a nested array. EG:
    Entity Post has an array of Comments. When I query for an array of Post, I want the Comments to be ordered by some field. I can achieve by mapping and sorting the Comments after but would like to do this at the query level if possible. Thanks !
    Alan Bradbury
    @alan-bradbury
    Hi, is it true that the ValueTransformer is run on a value in a where clause of find.
    Priyank753
    @Priyank753
    Hi @all
    I am creating table with @jointable but i dont know how to insert data in typeorm graphql which is created by join table.
    Alessandro Tagliapietra
    @alex88
    Hi everyone, after wasting so many hours I'm trying to find the code that actually finds the migration files, does anyone know where to find it? So I can debug why typeorm isn't able to find my migrations?
    Darksiderlm18
    @darksiderlm18

    Hi there!

    I'm having some problems with typeorm cleanup on jest afterAll tests. All tests pass correctly but executions never ends, console always throw:

    Test Suites: 8 passed, 8 total
    Tests:       47 passed, 47 total
    Snapshots:   0 total
    Time:        7.885 s, estimated 14 s
    Ran all test suites.
    Jest did not exit one second after the test run has completed.
    
    This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

    My afterAll code is:

    afterAll(async () => {
            await this.connection.close();
    });

    Have you ever had this problem? There is another way to solve it than by using --forceExit??

    simonbbyrne
    @simonbbyrne
    Is it possible to select a date like this in a select. The column is a datetime, but I want it as yyyy-mm-dd on completion of the sub query.
    image.png
    Really appreciated if someone can help, i'm still figuring things out!
    simonbbyrne
    @simonbbyrne
    Figured it out, if any has similar issue
    image.png
    Jimin Park
    @jimin4
    I can't find descriptions about findOneOrFail() in the official API doc.
    manish-sg
    @manish-sg

    @jimin4 - from their type defsin Repository.d.ts
    `/**

     * Finds first entity that matches given options.
     */
    findOneOrFail(id?: string | number | Date | ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;
    /**
     * Finds first entity that matches given options.
     */
    findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;
    /**
     * Finds first entity that matches given conditions.
     */
    findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;
    /**
     * Executes a raw SQL query and returns a raw database results.
     * Raw query execution is supported only by relational databases (MongoDB is not supported).`

    Works exactly the same as FindOne in terms of function signature so all docs from there are applicable

    manish-sg
    @manish-sg
    For @AfterLoad decorator in Entity Listener, is it possible to update the object and have it persist to DB? I'm having some trouble with that. Not doing anything special just updating a property. Do I need to call some save or update function.
    Currently with this approach: this.property = value
    manish-sg
    @manish-sg
    Got my answer - need to create a transaction to save the object!
    great-app-test
    @great-app-test

    Hi all, in typeorm entity manager API documentation, there is method named release, it is used to release query runner of an entity manager. It also says here it should only be used when query runner was created and managed manually.

    My question, what does "Used only when query runner was created and managed manually" means, and what is the use case for release to be used

    Sorry for bad english, english not my first language

    Marija Talevska
    @marijatalevska_gitlab
    Hi all, is there a way to serverless deploy typeorm with express apis to AWS?
    Dustin Lacewell
    @dustinlacewell
    Is there anyway to get a groupby where you get an object mapping group key to an array of model instances in each group?
    Justin
    @jayceekay
    does anyone know how i can compile and point to the ormconfig.json in the dist/ dir rather than the one at the root of my project?
    this is when running via node, not CLI
    Priyank753
    @Priyank753
    Hi All,
    can we get user request inside entity suscribers
    Mark V
    @vanakema

    Hey there everyone, we recently ran a psql CREATE INDEX CONCURRENTLY migration through the TypeORM migration system using queryRunner.connection.query, and instead of async/await-ing the response, we defined .then, .error, and .finally callbacks which would log when it was finished, so our webapp wouldn't be blocked while the concurrent index creation finished up.

    On one of our servers, we see the log for "starting" the migration, but we never saw our logs for the .then, .error, and .finally callbacks. This server was our instance with the most number of rows, and index creation definitely took longer than a couple minutes. But we verified in the DLL that the migration had successfully completed, despite never seeing our log statements.

    Looking in the PSQL logs, I see that T+4s after the migration started, this error was printed LOG: could not receive data from client: Connection reset by peer.

    Does TypeORM or node have some sort of thing that kills promises after 4s? And if so, why didn't the query get killed or error out? My intuition says that normally the query would get canceled if a promise timeout occured

    Karl Clement
    @karlclement
    Hi all, in Entity objects I have multiple @Generated columns and I keep getting errors null value in column "id" of relation "user" violates not-null constraint. Does the generation actually work or I need to set defaults in migrations? What does the @Decorator do?
    Key Kim
    @KimKiHyuk

    Hello there, I'm trying to convert raw mysql code to typeorm

    how can i convert under sql?

    select * from (
        select acv.id, acv.week_title, MAX(acs.id) as m from development.audition_chart_v2 acv
        inner join development.audition_chart_snapshots acs
            ON acv.id = acs.audition_chart_id and acv.status = 'DONE'
        group by acv.id
    ) as a
    left join development.audition_chart_snapshots acs2 on acs2.id = a.m
    Priyank753
    @Priyank753
    Hi All can we create multiple column in join table?
    Karl Clement
    @karlclement
    Hi all, in Entity objects I have multiple @Generated columns and I keep getting errors null value in column "id" of relation "user" violates not-null constraint. Does the generation actually work or I need to set defaults in migrations? What does the @Decorator do?
    k3ym
    @k3ym
    I'm looking for a way to order by a property calculated with @AfterLoad decorator... Anyone can help?
    Maarten van Veen
    @mvanveen82

    Hi all,
    I have a NestJS backend with TypeORM connected to a Postgres db.
    The db has a table building_daly_max with a column named visitdate of type date. Data like the following:

    building_id capacity wifi reserved workplaces visitdate
    119    395        0        2020-10-26
    13    354        0        2020-11-01
    111    31        0        2020-11-01
    120    530        0        2020-11-01

    The entity looks like this:

    @Entity({ name: 'building_daily_max' })
    export class BuildingDailyOccupancyEntity {
      @ManyToOne(() => BuildingEntity)
      @JoinColumn({ name: 'building_id' })
      building: BuildingEntity;
    
      @PrimaryColumn({ name: 'visitdate', type: 'date' })
      date: Date;
    
      @Column({ name: 'capacity' })
      capacity: number;
    
      @Column({ name: 'wifi' })
      maxWifiClientCount: number;
    
      @Column({ name: 'reserved' })
      maxReservationCount: number;
    
      @Column({ name: 'workplaces' })
      maxWorkplaceCount: number;
    }

    Querying by date only returns the first of the matching rows. However if I run the query typeorm performed manually in dbeaver I get all matching rows.
    Also when running the raw query with the entitymanager returns all the rows.
    Is this a bug in typeorm or am I missing something?

    // Returns first row only
        const result = await this.dailyOccupancyRepository.find({
            relations: ['building'],
            where: {
              date: '2020-11-16',
            },
          });
    
    // Returns first row only
        const result = await this.dailyOccupancyRepository.createQueryBuilder()
          .where('visitdate = :visitdate', { visitdate: '2020-11-16'})
          .getMany();
    
    // Returns all rows, but mapping to entities is a pain
        const result = await this.entityManager.query('select * from building_daily_max bdm inner join buildings b on bdm.building_id = b.building_id where bdm.visitdate = $1', ['2020-11-16']);
    2 replies
    Kevin Elliott
    @kevinelliott
    Hello, I need to set statement_timeout for a repository, any ideas?
    Alex McKay
    @alexandermckay
    Hi Gang, I am only using Javascript and cannot for the life of me work out how to use the UpdateDate column without using the Typescript decorator. I've had a look through the source code as well as the documentation but cannot find my answer. Does anyone know?
    Alex McKay
    @alexandermckay
    time works!
    Piotrek98
    @Piotrek98

    I have a problem with where clause and boolean value in TypeORM, like below:

    async getUserProjects(user: User, isFavorite: boolean): Promise<User[]> {
            const data = await this.conn.getRepository(User).find({
                where: {
                    userId: user,
                    favorite: isFavorite
                },
            })
      @Column({
        type: 'bool'
      })
      favorite: boolean;

    why this find not work properly and always return me value where favorite is false?
    when my fav == true return me all data when favorite == false..., can someone tell me what is wrong here?

    Sanjar B
    @the-sanjar
    hi! can I use typeorm with javascript (not typescript) and using ESM imports (import {} from '') without babel? I using nodejs 15 and Mozilla documentation said that decorators (@somedecorator) supports natively by last versions
    but I get an error
    @Entity()
    ^
    
    SyntaxError: Invalid or unexpected token