generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from amosproj/feat/xd-43
feat: Setup Prisma (XD-43)
- Loading branch information
Showing
16 changed files
with
40,833 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
APP_PORT=3000 | ||
APP_HOST=localhost | ||
APP_NAME=MyApp | ||
POSTGRES_HOST=db.example.com | ||
# Port number where the backend server will run | ||
BACKEND_PORT=3333 | ||
# Hostname for the backend server | ||
BACKEND_HOST=localhost | ||
# Name of the backend application | ||
BACKEND_NAME=MyApp | ||
# Hostname for the PostgreSQL database | ||
POSTGRES_HOST=localhost | ||
# Port number for the PostgreSQL database | ||
POSTGRES_PORT=5432 | ||
POSTGRES_USER=myuser | ||
POSTGRES_PASSWORD=mypassword | ||
# Username for accessing the PostgreSQL database | ||
POSTGRES_USER=amos | ||
# Password for the PostgreSQL database user | ||
POSTGRES_PASSWORD=amos | ||
# Name of the PostgreSQL database to be used | ||
POSTGRES_DB=amos | ||
|
||
# Full database connection URL constructed from the above PostgreSQL variables used for Prisma | ||
DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
apps/backend/src/app/config/interfaces/environment.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
"@nestjs/platform-express": "^10.0.2", | ||
"@nx/angular": "18.3.3", | ||
"@siemens/ix": "^2.2.1", | ||
"@prisma/client": "^5.13.0", | ||
"@siemens/ix-angular": "^2.2.1", | ||
"@siemens/ix-icons": "^2.1.0", | ||
"axios": "^1.6.8", | ||
|
@@ -36,7 +37,6 @@ | |
"dotenv": "^16.4.5", | ||
"lodash": "^4.17.21", | ||
"postgres": "^3.4.4", | ||
"prisma": "^5.13.0", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "~7.8.0", | ||
"ts-enum-util": "^4.1.0", | ||
|
@@ -97,6 +97,7 @@ | |
"lint-staged": "^15.2.2", | ||
"nx": "18.3.4", | ||
"prettier": "^3.2.5", | ||
"prisma": "^5.13.0", | ||
"stylelint": "^16.4.0", | ||
"stylelint-config-recess-order": "^5.0.1", | ||
"stylelint-config-standard": "^36.0.0", | ||
|
@@ -107,5 +108,8 @@ | |
"typescript": "~5.4.5", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"prisma": { | ||
"seed": "ts-node prisma/seed.ts" | ||
}, | ||
"packageManager": "[email protected]+sha512.831cf4c5f8b8374af71521d4d153db49d7086de615c2af7cb5e9d7eb8ba630ddac46fea495d643e552ef2e68a3aa99a3e5e9fbee8696702967504df5c59cb273" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Docs | ||
|
||
### Setup 🛠 | ||
|
||
Install Prisma | ||
|
||
```sh | ||
pnpm add -D @prisma/cli | ||
``` | ||
|
||
Install the Prisma Client | ||
|
||
```sh | ||
pnpm add prisma | ||
``` | ||
|
||
Initialize Prisma | ||
|
||
```sh | ||
pnpx prisma init | ||
``` | ||
|
||
generating the Prisma Client | ||
|
||
```sh | ||
pnpx prisma generate | ||
``` | ||
|
||
### Usage 🚀 | ||
|
||
First you need to apply the migrations to your database with the following command: | ||
|
||
```sh | ||
pnpx prisma migrate dev | ||
``` | ||
|
||
Then u can use the Prisma Client in your code to access your database: | ||
|
||
```ts | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
const allUsers = await prisma.user.findMany(); | ||
console.log(allUsers); | ||
} | ||
``` | ||
|
||
### Seeding the database 🌱 | ||
|
||
If you want to seed the database with some initial data, you can use the following command: | ||
|
||
```sh | ||
pnpx prisma db seed | ||
``` | ||
|
||
### Inspecting the database 🕵️♂️ | ||
|
||
If you want to inspect the database, you can use Prisma Studio. You can start it with the following command: | ||
|
||
```sh | ||
pnpx prisma studio | ||
``` | ||
|
||
Or you can also use alternative tools like [DataGrip](https://www.jetbrains.com/datagrip/) ... |
Oops, something went wrong.