Updating and deleting data from the shell
This again will be a simple recipe that will be looking at executing deletes and updates on a test collection. We won't be dealing with the same test data that we imported as we don't want to update/delete any of that, but instead, we will work on a test collection created for this recipe only.
Getting ready
For this recipe, we will create a collection called updAndDelTest
. We will require the server to be up and running. Refer to the Installing single node MongoDB recipe from Chapter 1, Installing and Starting the Server for instructions on how to start the server. Start the shell with the UpdAndDelTest.js
script loaded. This script will be available on the Packt website for download. To know how to start the shell with a script preloaded, refer to the Connecting to a single node in the Mongo shell with JavaScript recipe in Chapter 1, Installing and Starting the Server.
How to do it…
- Start the MongoDB shell and preload the script:
...