1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| @Module({ imports: [ SequelizeModule.forRoot({ dialect: 'mysql', host: 'localhost', port: 3306, username: 'root', password: 'root', database: 'test', loggin: false, models: [], }), forwardRef(() => AbcModule), ], })
import { Column, CreatedAt, Model, Table, UpdatedAt } from 'sequelize-typescript'
@Table({ tableName: 'users' }) export class UserModel extends Model { @Column username: string;
@CreatedAt @Column({ field: 'created_at' }) createdAt: Date; }
@Module({ imports: [ SequelizeModule.forFeature([UserModel]) ], controllers: [UsersController], providers: [UsersService], exports: [SequelizeModule] }) export class UsersModule {}
@Injectable() export class UsersService { constructor ( @InjectModel(UserModel) private readonly userModel: typeof UserModel ) {} }
|