$ docker-compose up -d
$ npm install @nestjs/typeorm typeorm pg
$ curl -d '{
"name": "Coffee #1",
"brand": "Nesti",
"flavors": ["chocolate"]
}' \
-H "Content-Type: application/json" \
-X POST http://localhost:3000/coffees/ \
| python -m json.tool
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees \
| python3 -m json.tool
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees/1 \
| python3 -m json.tool
$ nest generate class coffees/entities/flavor.entity --no-spec
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees \
| python3 -m json.tool
returns:
[
{
"id": 2,
"name": "Coffee #2",
"brand": "Nesti",
"flavors": []
},
{
"id": 1,
"name": "Coffee #1",
"brand": "Nesti",
"flavors": []
}
]
$ curl -d '{
"name": "Coffee #4",
"brand": "Nesti",
"flavors": ["caramel", "chocolate"]
}' \
-H "Content-Type: application/json" \
-X POST http://localhost:3000/coffees/ \
| python -m json.tool
{
"brand": "Nesti",
"flavors": [
{
"id": 1,
"name": "caramel"
},
{
"id": 2,
"name": "chocolate"
}
],
"id": 3,
"name": "Coffee #4"
}
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees \
| python3 -m json.tool
[
{
"id": 3,
"name": "Coffee #4",
"brand": "Nesti",
"flavors": [
{
"id": 1,
"name": "caramel"
},
{
"id": 2,
"name": "chocolate"
}
]
},
{
"id": 2,
"name": "Coffee #2",
"brand": "Nesti",
"flavors": []
},
{
"id": 1,
"name": "Coffee #1",
"brand": "Nesti",
"flavors": []
}
]
$ nest generate class common/dto/pagination-query.dto --no-spec
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees?limit=1 \
| python3 -m json.tool
$ curl \
-H "Content-Type: application/json" \
-X GET http://localhost:3000/coffees?offset=1 \
| python3 -m json.tool
$ nest generate class events/enities/event.entity --no-spec
$ npx typeorm migration:create -n CoffeeRefactor
write migrations
$ npm run build
$ npx typeorm migration:run
$ npx typeorm migration:revert
// Not Works for me
$ npx typeorm migration:generate -n SchemaSync
Marley
Any questions in english: Telegram Chat
Любые вопросы на русском: Телеграм чат