- to have commit smoothly, go to settings -> developer settings -> personal access token -> generate new one and paste in as password when run git push origin branch
- Connect db to port 5423 on postgres
- Create tables if not existed at
postgres
database, they are created. - There are models like users posts, there is a module connection define as connection. At router, you import connection, and use connection to connect with each model based on routes hits. On running server, server would check connection module first, then create all models (dbs) connected to it at routes or other places
- Create tables if not existed at
-
install remote container
-
select New Dev Container
- Select Node.js & Postgresql
- It creates docker-compose which run node first, then create a postgres from image
- You can add command section at then end
- Select Node.js & Postgresql
-
Create launch.json as below using nodemon
{
"version": "0.2.0",
"configurations": [
{
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"name": "nodemon",
"program": "${workspaceFolder}/server.js",
"request": "launch",
"restart": true,
"runtimeExecutable": "nodemon",
"skipFiles": [
"<node_internals>/**"
]
}
]
}
brew info postgres
- Postgresql command line
- When running on container then use this to access postgres
sudo apt-get update
sudo apt-get install -y postgresql-client
psql -h localhost -U postgres -d postgres
\c DBNAME -> switch dbs
\l -> list of databases
\dt -> show all tables
select * from "Users"; -> show table
- To get max number of people in each country, use group by country, select Max(anyAttribute) and order by ... DESC
- docker tag app_image infroger/app_image:1
POST
{
"name": "Amir khan",
"email": "[email protected]"
"bio": ""
}
GET
PUT, to replace the whole resource. several puts is same as one single put
PATH, partialy update resource. several path are different
POST
{
"name": "Amir khan",
"email": "[email protected]"
"bio": ""
}
GET
PUT, to replace the whole resource. several puts is same as one single put
PATH, partialy update resource. several path are different
- posts/:PostId/comments
POST
{
"title": "aa",
"content": "[email protected]"
"postid": ""
"like": ""
"dislike": ""
"ipaddress": ""
"city": ""
country: ""
}
GET /posts/:PostId/comments
# Comments on Comments
post /posts/:postId/comments/:commentid
- install dotenv and run
config()
- Then inside
process.env
you access the.env
variables