π Setup¶
1οΈβ£ Create a new project and publish a cluster on MongoDB Atlas.
2οΈβ£ Run a local database for development setup:
- π» This allows you to work offline and speeds up development.
3οΈβ£ Inside your MongoDB Atlas project:
- π Click on [Network Access] then [+ Add IP Address].
- π Enter: 0.0.0.0/0
in the [Access List Entry].
- π Why: This allows access from your machine and from deployed environments (like Vercel).
4οΈβ£ Environment variable setup:
- π If you havenβt already, rename .env.example
to .env.local
.
- π Then add your connection string to MONGODB_URI
inside .env.local
.
π οΈ Mongoose (Optional)¶
- ποΈ Why use Mongoose:
- It simplifies working with MongoDB.
-
It offers helpful features out of the box.
-
π Model organization:
- Define your models inside the
/models
folder. -
Add any new models there.
-
β Frontend optimization:
- The
toJSON
plugin has been added to all models to remove the_id
and__v
fields. - If you set
private: true
on any field, it will be excluded from the response. - For example, you can make the
email
field private so it wonβt be sent to the frontend.