Setting up a batch file for MongoDB
It's always easy to create a batch file to start MongoDB, and it's best to create a script file to start Mongo. This way, we won't have an error with the configuration. This would also save us a lot of time.
- Create a
mongodbstart.bat
file. - Edit the file and type in the following command and save it:
cd E:\MONGODB\mongo\bin mongod -dbpath e:\mongodata\db
The next time you want to start MongoDB, just click on the batch file.
Order use case with Spring and MongoDB
Let us look at the Order use case to implement a simple CRUD operation using Spring and MongoDB. We are performing CRUD operations on Product, Customer, and Order documents. The scenario is this: a customer selects a product and places an order.
Following is the Order use case. The actor is the application user and will have the following options:
- CRUD operation on Product Document
- CRUD operation on Customer Document
- CRUD operation on Order by selecting Product and Customer
- Saving the Product Document Object ID and Customer Document Object ID in Order Document