Simple User, Game relation and CRUD example of Node.js Rest APIs with Express, PostgreSQL & Prisma
Get start ✨
-
Clone the repository:
git clone https://github.com/tugu-tmrbtr/server-postgres.git cd server-postgres
-
Install the dependencies:
# Using npm npm i # Using Yarn yarn
-
Start the Postgres server:
# Using brew brew services start postgresql@14
-
Connect the created server:
DATABASE_URL="postgresql://<username>:<password>@<host_name>:<port>/<database_name>?schema=public"
Create a .env file at the root of the project populate it with the url of your database.
-
Start the development server:
# Using npm npm run server # Using Yarn yarn run server
Now you should be able to see the project running at localhost:8080.
-
Open
./server.js
in your editor and start experimenting!
-
Migrate the SQL schema
npx prisma migrate dev
Create migrations from your Prisma schema, apply them to the database, generate artifacts (e.g. Prisma Client)
-
Launch Prisma Studio
npx prisma studio
Now you should be able to see the studio running at localhost:5555.
-
Database Pull
npx prisma db pull
Pull the schema from an existing database, updating the Prisma schema.
-
Database Push
npx prisma db push
Push the Prisma schema state to the database.