Executing update and delete operations using a Java client
In the previous recipe, we saw how to execute find
and insert
operations in MongoDB using the Java client; in this recipe, we will see how updates and deletes work in the Java client.
Getting ready
For this recipe, we will start a standalone instance. Refer to the Installing single node MongoDB recipe from Chapter 1, Installing and Starting the Server for instructions on how to start the server.
The next step is to download the Java project, mongo-cookbook-javadriver
, from the Packt website. This recipe uses a JUnit test case to test out various features of the Java client. In this whole process, we will use some of the most common API calls and thus learn to use them.
How to do it…
To execute the test case, one can either import the project in an IDE-like Eclipse and execute the test case or execute the test case from the command prompt using Maven.
The test case that we are going to execute for this recipe is com.packtpub.mongo.cookbook...