Sv-Primsa-MongoDB Svelte Themes

Sv Primsa Mongodb

Full Stack Application Using : Sveltekit + Prisma + MongoDB

Svelte + Prisma + MongoDB

Creating a project

   npm create svelte@latest project-name
   cd project-name
   npm i
   npm run dev -- --open

Project will open on Port localhost:5173

Install Prisma + Prisma Client

   npm install prisma --save-dev
   npx prisma
   npx prisma init

This will Install Prisma
Also add Prisma Folder and create .env File

Now Add MongoDB Atlas Url into .env file

Example : 

mongodb+srv://<username>:<password>@bob.qousp1y.mongodb.net/test
Add Your Username & Password 
Add your Database Name 
/test indicates Database Name

Install Prisma Client

   npm install @prisma/client

Add Your Model into schema.prisma

    model Article {
        id      String   @id @default(auto()) @map("_id") @db.ObjectId
        title   String
        desc    String
    }
    npx prisma generate
  • Add Queries into +page.server.js file in route Folder
  • Now copy the +page.server.js file

Top categories

Loading Svelte Themes