Levantar el proyecto
CREATE ROLE sheep_bah LOGIN SUPERUSER PASSWORD 'ship01234';
create database db_sheep
with
owner = sheep_bah
encoding = 'UTF8'
connection
limit = -1;
DATABASE_URL=postgres://sheep_bah:ship01234@127.0.0.1:5432/db_sheep
npm i
npm run migration:run
Listo! este proyecto sirve para ejecutar las migraciones, no debe estar corriendo.
Generar nueva migración
Luego de haber creado la entidad como un archivo .ts
, ejecute lo suguiente.
npm run migration:generate --name=init
# Luego
npm run migration:run
Crear proyecto ts typeOrm dede 0
npx typeorm init --name db.sheep.entities --database postgres
Eliminar base de datos en caso de limpiar la DB
drop database db_sheep
-- Luego cree nuevamente la base
create database db_sheep
with
owner = sheep_bah
encoding = 'UTF8'
connection
limit = -1;
Crear proyecto NestJs desde 0
nest new <proyecto>
Crear crud
nest g resource <module>
Eliminar archivos innecesarios
- Eliminar los archivos
Controller
yService
- Modificar el
app.module.ts
y eliminar las referencias de los archivos antes mencionados
Instalar el validador DTO
npm i --save class-validator class-transformer
- Agregar
app.useGlobalPipes(new ValidationPipe());
en elmain.ts