benjamin-white / ondemand

Built with React, nextjs and Prisma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NEXT STEPS:

strengthen user system add extra user funcs. build other features / pages Passport Redux / ApolloGraphQL Express Next Routing

DATABASE

Install PostgreSQL

sudo apt update
sudo apt install postgresql postgresql-contrib
psql --version
sudo service start postgresql
service postgresql status
sudo passwd postgres

After running the above commands a postgresql database server should be running and can be connected to for local dev using the default user postrgres

Create database

sudo -u postgres psql # To start the postgresql cli
\dt # to list users
CREATE DATABASE "database-name"; # You can also use \connect to connect to an existing database
CREATE TABLE users (id serial, name text);
INSERT INTO users (name) VALUES ('John'); # Add example data
SELECT * FROM users; # Check data exists
\q # to exit

Install Prisma

npm install prisma --save-dev
npx prisma init

Tell Express where the database is

Add the database location into the dotenv js file where the format is DATABASE_URL="postgresql://USER:PASSWORD@localhost/DBNAME/prisma2?schema=public"

Write a schema in file schema.prisma, then migrate it

npx prisma db push
npx prisma studio # to write stub data, works like PHPMyadmin

Add and setup Prisma Client to connect Next to the DB

npm install @prisma/client
npx prisma generate # run after any chnage to the schema

GENERAL REFs https://dev.to/aurelkurtula/introduction-to-nextjs---adding-express-and-mongo-to-the-project-2d38 https://redux.js.org/introduction/learning-resources https://ethereum.org/en/developers/docs/dapps/ https://nextjs.org/docs/advanced-features/custom-server https://nextjs.org/docs/authentication

About

Built with React, nextjs and Prisma


Languages

Language:TypeScript 88.5%Language:CSS 11.5%