inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

typeorm seeding, migration

typeorm 0.3버전에 아직 seed기능 안나온걸까요?

1191

초간단

작성한 질문수 5

0

$ yarn run seed
yarn run v1.22.17
$ ts-node ./node_modules/typeorm-extension/dist/cli/index.js seed -d ./dataSource.ts
query: SELECT VERSION() AS `version`
typeorm-extension seed

Populate the database with an initial data set or generated data by a
factory.

Options:
  -h, --help        Show help                                      [boolean]
  -r, --root        Path to the data-source / config file.
                         [default: "/Users/teetee6/code_react/sleact/hback"]
  -c, --connection  Name of the connection on which run a query.
                                           [deprecated] [default: "default"]
  -f, --config      Name of the file with the data-source configuration.
                                         [deprecated] [default: "ormconfig"]
  -d, --dataSource  Name of the file with the data-source.
                                                    [default: "data-source"]
  -s, --seed        Specify the seed class to run.
  -v, --version     Show version number                            [boolean]

TypeError: connection.createQueryBuilder is not a function
    at CreateInitialData.run (/Users/teetee6/code_react/sleact/hback/src/database/seeds/create-initial-data.ts:40:8)
    at /Users/teetee6/code_react/sleact/hback/node_modules/typeorm-extension/src/seeder/module.ts:125:18
    at Generator.next (<anonymous>)
    at fulfilled (/Users/teetee6/code_react/sleact/hback/node_modules/typeorm-extension/dist/seeder/module.js:5:58)
error Command failed with exit code 1.

4달전 즈음의 공지사항에 typeorm 0.3버전이 Seeding이 아직 호환 안된다고 되있던데
아직 안나온 거겟죠,,

 

export default class CreateInitialData implements Seeder {
  public async run(factory: Factory, connection: Connection): Promise<any> {
    await connection
      .createQueryBuilder()
      .insert()
      .into(Workspaces)
      .values([{ id: 1, name: 'Sleact', url: 'sleact' }])
      .execute();
    await connection
      .createQueryBuilder()
      .insert()
      .into(Channels)
      .values([{ id: 1, name: '일반', WorkspaceId: 1, private: false }])
      .execute();
  }
}

express nodejs NestJS TypeORM

답변 1

1

제로초(조현영)

공식문서를 보세요. 강좌에서도 저 소스코드를 쓰지 않았습니다. 강의에서 나온 소스를 사용하세요.

https://github.com/tada5hi/typeorm-extension#seed

강의자료는 어디서 다운받나요?

0

110

3

질문 있습니다.

0

294

3

코드 편집기 확장 프로그램

0

209

2

(질문)비밀 저장소에 접근하기 위한 인증 정보는 로컬 .env에 저장하는지?

0

143

2

(질문)외부 저장소를 통한 환경변수 불러오기 비동기 질문

0

166

3

로그인을 해도 LoggedInGuard쪽에서 false값이 나옵니다.

0

151

2

로그인방법이 고민됩니다.

0

190

2

yarn seed 명령어 실행 시 데이터 삽입 안됨

0

296

4

yarn run db:create 시에 발생하는 데코레이터 오류

0

242

2

npm run db:create 시에 발생하는 decorating 오류

0

231

2

RxJS 디버깅 질문 있습니다.

0

187

3

CacheManager에 대해 질문 있습니다.

0

173

2

로깅은 어떻게 하는게 효율적일까요?

0

222

1

CORS 질문 있습니다.

0

417

2

쿠키 옵션에 대해서 질문 있습니다.

0

184

2

로그아웃 요청이 403 forbidden 에러가 나는데 왜그런걸까요??

0

446

1

401 unauthorized문제

0

285

1

가드의 장점에 대해서 질문이 있습니다.

0

225

1

로그 관리에 대해 질문 있습니다.

0

251

2

CORS 에러 질문 있습니다.

0

317

2

배포 환경 DB 연결 질문 있습니다.

0

410

2

socket io 미 연결 문제 (nest & flutter)

1

1151

3

no elements in sequence 에러 관해서 질문이 있습니다.

0

451

1

start:dev-backup으로 돌리면 핫 리로딩이 되요 정상인가요?

0

319

1