A | B | C | |
---|---|---|---|
1 | |||
2 | Module-6: Installation and Explore Read and Write Queries | ||
3 | |||
4 | 6-2 Install express, typescript, mongoose, ts-node-dev | ||
5 | Mongodb for mac: | https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/?fbclid=IwAR0hFAF9eybbUnvAHxyBo6LUmxP9olaxiWDsJdfrABkqm3ihOLn8dbhft78 | |
6 | Mongodb for Ubuntu | https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/?fbclid=IwAR1a27_rh2bBMds5yDrOcBmY72muuvnVptpsvsKMmeXPvpiH81ljdA_lqkc | |
7 | Install for ubuntu | https://www.youtube.com/watch?v=HSIh8UswVVY | |
8 | Mongodb Compas for mac: | https://www.mongodb.com/try/download/compass | |
9 | Start mongoDB compas on mac: | ||
10 | start command | brew services start mongodb-community@7.0 | |
11 | stop command | brew services stop mongodb-community@7.0 | |
12 | Mac m1 | Start Update 2025 | brew services start mongodb/brew/mongodb-community |
13 | Mac m1 | Start Update 2025 | brew services start mongodb/brew/mongodb-community |
14 | |||
15 | Postgresql + pgadmin | ||
16 | mac +ubuntu | 𝐎𝐩𝐞𝐧 𝐭𝐞𝐫𝐦𝐢𝐧𝐚𝐥 𝐚𝐧𝐝 𝐠𝐨 𝐭𝐨 𝐫𝐨𝐨𝐭 -> sudo su postgres -> psql -> CREATE ROLE sscl WITH LOGIN SUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION PASSWORD 'sa' | |
17 | |||
18 | |||
19 | |||
20 | |||
21 | |||
22 | run mongodb local give the command in the terminal brew services start mongodb-community@6.0 | ||
23 | Prisma Commands | ||
24 | |||
25 | - when we change anything in the schema file or model | ||
26 | then we use `npx prisma generate` to fetch the change in the prisma client. | ||
27 | |||
28 | - when we run the query in the database then we need to | ||
29 | `npx prisma migrate dev` | ||
30 | |||
31 | --- | ||
32 | |||
33 | -- Any Change in the model | ||
34 | - `npx prisma migrate dev` [database e add korbe new column or change] | ||
35 | - `npx prisma migrate --name 20230830153102_emial_unique` | ||
36 | - `npx prisma generate` [only locally add the new column not in the database] | ||
37 | |||
38 | ### vsc extention prisma | ||
39 | ### 01.Install prisma | ||
40 | - `yarn add -y` | ||
41 | - ` yarn add prisma typescript ts-node @types/node --save-dev` | ||
42 | - `npx tsc --init` | ||
43 | - `npx prisma init` | ||
44 | |||
45 | ### 02.Database connection: | ||
46 | |||
47 | `DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"` | ||
48 | - For postgres | ||
49 | postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA | ||
50 | ### 03.Creating the database schema[Using Prisma Migrate] | ||
51 | - make a model in `schema.prisma` file | ||
52 | - After creating a model then migrate it(Migrate will make structure in the database. Simple create the table ). | ||
53 | - `npx prisma migrate dev --name init ` | ||
54 | ### 04.Install and generate Prisma Client[For making operation in table CRUD] | ||
55 | - `npm install @prisma/client` | ||
56 | |||
57 | - Create a new file named `index.ts ` | ||
58 | ## Run Comman index. [`npx ts-node index.ts`] | ||
59 | |||
60 | |||
61 | -- Any Change in the model | ||
62 | - `npx prisma migrate dev` [database e add korbe new column or change] | ||
63 | - `npx prisma migrate --name 20230830153102_emial_unique` | ||
64 | - `npx prisma generate` [only locally add the new column not in the database] | ||
65 | |||
66 | |||
67 | |||
68 | |||
69 | Testing | Simply veryfying if something works as expected | |
70 | |||
71 | |||
72 | |||
73 |