{"id":21523617,"url":"https://github.com/umarilly/nest-js-and-prisma-project","last_synced_at":"2026-04-14T04:02:53.347Z","repository":{"id":262082014,"uuid":"885327889","full_name":"umarilly/Nest-js-and-Prisma-Project","owner":"umarilly","description":"Nest.js \u0026 Prisma Project is a simple CRUD application built using Nest.js and Prisma, designed for practice. It leverages a MySQL Docker image for database management, making it easy to set up and run in a containerized environment. The app provides basic Create, Read, Update, and Delete operations for managing entities.","archived":false,"fork":false,"pushed_at":"2024-11-21T12:19:09.000Z","size":108,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T05:09:50.220Z","etag":null,"topics":["docker","docker-compose","mysql","mysql-database","nestjs","prisma","prisma-client","prisma-orm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umarilly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T11:26:19.000Z","updated_at":"2024-11-21T12:21:55.000Z","dependencies_parsed_at":"2024-11-10T12:34:12.602Z","dependency_job_id":"fed85be0-5f1b-4c37-b21c-2cab2ee28939","html_url":"https://github.com/umarilly/Nest-js-and-Prisma-Project","commit_stats":null,"previous_names":["umarilly/nest-js-and-prisma-project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarilly%2FNest-js-and-Prisma-Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarilly%2FNest-js-and-Prisma-Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarilly%2FNest-js-and-Prisma-Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umarilly%2FNest-js-and-Prisma-Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umarilly","download_url":"https://codeload.github.com/umarilly/Nest-js-and-Prisma-Project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244081823,"owners_count":20395162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","mysql","mysql-database","nestjs","prisma","prisma-client","prisma-orm"],"created_at":"2024-11-24T01:18:49.601Z","updated_at":"2026-04-14T04:02:53.308Z","avatar_url":"https://github.com/umarilly.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Nest.js \u0026 Prisma Project\n\nNest.js \u0026 Prisma Project is a simple CRUD application built using Nest.js and Prisma, designed for practice. It leverages a MySQL Docker image for database management, making it easy to set up and run in a containerized environment. The app provides basic Create, Read, Update, and Delete operations for managing entities, demonstrating the integration of Prisma as an ORM with Nest.js for seamless database interactions.\n\n## Install the Nest.js CLI and Prerequisites:\n- Install Node.js first. If you have already installed Node.js, then enter `node --version` and `npm --version` to verify their installation.\n- Then run the following command: `npm install -g @nestjs/cli`\n- Verify the Nest.js CLI: `nest -v` or `nest --version`\n- Create a new project: `nest new \u003cproject-name\u003e` (e.g., `nest new my-project`)\n- Use the package manager: `npm`, `yarn`, or `pnpm` - I am choosing npm for now. (If you want to use yarn or pnpm, then install them first.)\n- Switch to the project directory: `cd \u003cdirectory-name\u003e`\n- To run the server, enter `npm run start` - (There are different startup scripts, and you can also set them from the package.json file.)\n\n## Setup Prisma\n- Enter `npm install prisma --save-dev` to install Prisma.\n- Then enter `npx prisma init` or `npx prisma init --datasource-provider \u003cdatabase-name\u003e`.\n- For instance, `npx prisma init --datasource-provider \u003cSQLite or PostgreSQL or MySQL\u003e`.\n- After this, a prisma folder and a .env file will be created.\n- The prisma folder will contain a migrations folder and schema.prisma, and the .env file will contain the Database URL.\n- Open the schema.prisma inside the prisma folder and start writing your model.\n- After writing the model, just save the file and close it.\n\n## Database Source Provider\n- Choose the database, e.g., MySQL, PostgreSQL, or any other.\n- I am choosing MySQL for now; the process is quite similar for all other databases.\n- Then, go to the .env file and create the following:\n  - MYSQL_DATABASE=\"\"\n  - MYSQL_ROOT_PASSWORD=\"\"\n- Name your database and also create a password for your database.\n\n## Dockerization\n- Install Docker Desktop, or you can use any other method if you have a different OS.\n- Create a docker-compose.yaml file in the root of your project directory and write the service for MySQL.\n- After creating it, go to the root of the project, open the terminal, and run `docker-compose up`.\n\n## Database URL Changes\n- Change the database URL in .env.\n- It looks like the following:\n```bash\nDATABASE_URL=\"mysql://root:password@127.0.0.1:3306/nest_prisma_project\"\n```\n- Also, change the database provider in the prisma.schema file if your provider is not PostgreSQL.\n- Then, you can write the schema of your tables inside the schema.prisma file.\n- Then enter `npx prisma migrate dev --name init` to generate the schema and create the first migration, i.e., `init`.\n- To push and deploy the schema, use `npx prisma migrate push` and `npx prisma migrate deploy`.\n\n## Implementation\n- Here, I am writing the implementation of my project.\n\n### Creating Modules, Service, and Resource\n- Also known as database service, I have named it database service.\n- Create a new database module:\n  - `nest g module database` - This will create a new database module file in the database directory within the src folder.\n  - This will also update the `app.module.ts` to add the `database.module.ts` to it.\n- Create a new database service:\n  - Enter `nest g service database`\n  - This will create `database.service.spec.ts` and `database.service.ts` and update the `database.module.ts` to add the service.\n- Now create a resource - a resource basically creates a module, service, and controller file in one go.\n- Enter `nest g resource products`\n- This will create a complete CRUD structure (products directory: module, service, and controller).\n- Change these according to your requirements.\n\n### Working with Relations\n- Create different models according to your requirements. I am creating description, reviews, and tag models.\n- For 1-to-1, 1-to-many, and many-to-many relations with the products model respectively.\n- Migrate the database using `npx prisma migrate dev --name relations`.\n- This will create a new migration with the name `relations`.\n\n## Running the Application\n- To start the application, run `npm run start`\n- The application will be available at `http://localhost:3000`.\n- Use tools like Postman or Insomnia to test the API endpoints.\n\n## Testing\n- Nest.js provides a robust testing framework.\n- Create unit tests for your services and controllers using Jest.\n- Run tests using `npm run test`.\n\n## Conclusion\n- This project demonstrates a basic CRUD application using Nest.js and Prisma.\n- It covers setting up the environment, creating modules and services, and working with database relations.\n- For more advanced features, refer to the official documentation of Nest.js and Prisma.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumarilly%2Fnest-js-and-prisma-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumarilly%2Fnest-js-and-prisma-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumarilly%2Fnest-js-and-prisma-project/lists"}