fix: seeder

This commit is contained in:
ilham
2022-01-26 16:24:11 +07:00
parent b0d23b5551
commit c301af2d8d
4 changed files with 148 additions and 8 deletions

View File

@@ -48,6 +48,8 @@ import { MulterModule } from '@nestjs/platform-express';
synchronize: true,
autoLoadEntities: true,
logging: true,
seeds: ['src/seeds/**/*{.ts,.js}'],
factories: ['src/factories/**/*{.ts,.js}'],
namingStrategy: new SnakeNamingStrategy(),
};
},

17
src/seeder/roles.ts Normal file
View File

@@ -0,0 +1,17 @@
import { Factory, Seeder } from 'typeorm-seeding'
import { Connection } from 'typeorm'
import { Roles } from '../configurable/entities/roles.entity'
export default class CreateUsers implements Seeder {
public async run(factory: Factory, connection: Connection): Promise<any> {
await connection
.createQueryBuilder()
.insert()
.into(Roles)
.values([
{ id: '3196cdf4-ae5f-4677-9bcd-98be35c72321', name: 'Admin' },
{ id: '3196cdf4-ae5f-4677-9bcd-98be35c72322', name: 'Supervisor' },
])
.execute()
}
}