MongoDB — Ship Fast ⚡️

You don't have to use MongoDB, but you'll need a database for saving users who log in, products, orders, etc...

Setup
  • Create a new project and deploy a cluster on MongoDB Atlas
  • Add you connection string to MONGODB_URI in .env.local & in your prod deployment
  • Tip: Run a local database for your dev setup so you can work offline and it's faster

Mongoose (optional)

Mongoose makes it easier to deal with MongoDB and has some cool features.
Models are defined in the folder /models. Add any new models there.
The plugin toJSON is added to all models to remove the _id and __v (easier on front-end). Also if you add
private: true
to any field it will be removed from the response. I.e. make email private so it's not sent to the front-end.