Start the containers with
make
And every time you visit the website, you'll get a number that is incremented by 1 in postgres every time:
curl localhost:3000
You can use docker compose exec db bash
to go into the database container, and psql --username=foo --dbname=bar
to view the database, where you can use \d user
to view the "user" table
- Check if postgres is running with
ps aux | grep postgres
- Start the postgres server with
sudo systemctl start postgresql
- Connect to the postgres server with
sudo -u postgres psql
- Stop the postgres server with
sudo systemctl stop postgresql
- Connect to the container's postgres with
psql -h localhost -U postgres
- Create user with
curl localhost:3000/users -H 'Content-Type: application/json' -d '{"id":1,"firstName":"Foo","lastName":"Bar","isActive":true}'
To view the user table's types, use \d user
To view the contents of the table, use table public.user
cd containers/nestjs
npx @nestjs/cli new .
npm install @nestjs/typeorm typeorm pg