Creación de Entidades en ORM para Tiendas Virtuales

Clase 10 de 36Curso de NestJS: Persistencia de Datos con TypeORM

Resumen
// src/products/entities/product.entity.ts import { PrimaryGeneratedColumn, Column, Entity } from 'typeorm'; @Entity() export class Product { @PrimaryGeneratedColumn() id: number; @Column({ type: 'varchar', length: 255, unique: true }) name: string; @Column({ type: 'text' }) description: string; @Column({ type: 'int' }) price: number; @Column({ type: 'int' }) stock: number; @Column({ type: 'varchar' }) image: string; }
// src/products/products.module.ts import { TypeOrmModule } from '@nestjs/typeorm'; import { Product } from './entities/product.entity'; @Module({ imports: [TypeOrmModule.forFeature([Product])], // 👈 Include entitites controllers: [ProductsController, CategoriesController, BrandsController], providers: [ProductsService, BrandsService, CategoriesService], exports: [ProductsService], }) export class ProductsModule {}