작성
·
1.1K
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이 아직 호환 안된다고 되있던데
아직 안나온 거겟죠,,
/database/seeds/create-initial-data.ts
Connection이 deprecated되었다던데 제가 못찾은 새로운 seed방법이 나온걸까요 검색해봐도 안나오는데 아니면 없는걸까요
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();
}
}
답변 1
1
공식문서를 보세요. 강좌에서도 저 소스코드를 쓰지 않았습니다. 강의에서 나온 소스를 사용하세요.
https://github.com/tada5hi/typeorm-extension#seed