Giter Club home page Giter Club logo

Comments (10)

hirsch88 avatar hirsch88 commented on May 28, 2024 3

Hi @brunoti
Could you please provide me your entity ApplicationToken for a full analysis.

Try to change the path to your entity. Maybe it can't find your entitiy.
from:

import { ApplicationToken } from '@backend/entities/ApplicationToken';

to static:

import { ApplicationToken } from '../entities/ApplicationToken';

from typeorm-seeding.

eranshmil avatar eranshmil commented on May 28, 2024 2

This also happened to me, fixed that by setting the TYPEORM_ENTITIES environment variable.

from typeorm-seeding.

hirsch88 avatar hirsch88 commented on May 28, 2024 2

The error TypeError: this.subQuery is not a function is because typeorm could not find any entities.

Please check your paths in your config file

from typeorm-seeding.

hirsch88 avatar hirsch88 commented on May 28, 2024 1

Hi @NMontilva

Sure the path to your entites is correct?

"entity/*.ts" should this be "src/**/*.entity{.ts,.js}"

from typeorm-seeding.

NMontilva avatar NMontilva commented on May 28, 2024 1

Hello @hirsch88

Thank you! That was it.

from typeorm-seeding.

NMontilva avatar NMontilva commented on May 28, 2024

I'm using ormconfig.json and I'm getting the same error as @brunoti
I already set the entities variable in the .json and nothing. Same error

Here is my ormconfig.json

{ "type": "mysql", "host": "localhost", "port": 3306, "username": "a_username", "password": "a_password", "database": "a_db", "entities": ["entity/*.ts","dist/**/*.entity{.ts,.js}"], "synchronize": true, "seeds": ["src/database/seeds/**/*.seed.ts"] }

UPDATE:

I downgraded typeorm to 0.2.22 and it's working again.

from typeorm-seeding.

ahmedNY avatar ahmedNY commented on May 28, 2024

I had the same issue

from typeorm-seeding.

davicedraz avatar davicedraz commented on May 28, 2024

Relatable, exactly the same error here!

#53 (comment) Downgrading typeorm to 0.2.22 doesn't work either

There are how my files look like:

maratona.entity.ts

import { Entity, Column, CreateDateColumn, PrimaryGeneratedColumn } from 'typeorm';

@Entity({ name: 'maratonas' })
export class Maratona {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  title: string;

  @Column()
  date: Date;

  @CreateDateColumn()
  created_at?: Date;
}

maratona.seed.ts

import { Connection } from 'typeorm';
import { Factory, Seeder } from 'typeorm-seeding';

import { Maratona } from '../entities/maratona.entity';

export default class CreateUsers implements Seeder {
  public async run(factory: Factory, connection: Connection): Promise<any> {
    return await connection
      .createQueryBuilder()
      .insert()
      .into(Maratona)
      .values([
        { title: 'Full Cycle: Arquitetura e Estudo de Caso', date: `${new Date('04/05/2020')}` }
      ])
      .execute();
  }
}

.env

TYPEORM_CONNECTION=sqlite
TYPEORM_DATABASE=database.sqlite
TYPEORM_ENTITIES=src/**/*.entity{.ts,.js}
TYPEORM_MIGRATIONS=src/database/migrations/**/*.ts
TYPEORM_MIGRATIONS_DIR=src/database/migrations
TYPEORM_SEEDING_FACTORIES=src/database/factories/**/*{.ts,.js}
TYPEORM_SEEDING_SEEDS=src/database/seeds/**/*{.ts,.js}

from typeorm-seeding.

nrctkno avatar nrctkno commented on May 28, 2024

In addition to the path in ormconfig, check if your entities were imported in your module.

from typeorm-seeding.

aphofstede avatar aphofstede commented on May 28, 2024

For posterity: If you're using e.g. entities/index.ts to list your entities, make sure it is being exported there.

from typeorm-seeding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.