In this exercise, you’ll modify values in the document you created in the first exercise (the document whose
last field value is
Grey). To update the document, you’ll use features available on the Collection Tab.
To update the document
1. Retrieve the “Grey” record and display it in Tree View if you did not leave it open from the previous exercise. The record should look similar to the following figure.
2. Your first step is to add a value to the interests array. Right-click the interests field node, point to Array Element, and click Add Element.
3. In the Add Element text box, ensure that String is selected from the Type drop-down list.
4. In the Value text box, type Software and then click Add Element. Studio 3T adds the value to the
5. The next step is to update the
device field. Locate the field in the data grid, double-click the
Apple iPhone value to select it, type Android phone, and press Enter. The device field is updated to the new value.
The following figure shows the
device fields with their new values, as they appear in Tree View.
6. On the Result tab toolbar, click the Edit Document button. Studio 3T opens the document in the Document JSON Editor dialog box, as shown in the following figure. Notice that the
interests array includes the updated values.
7. The next step is to add the
Database Design value to the
interests array. To add the value, type a comma after the
Software value (after the closing quotation marks), and then press Enter to add a new line. On the new line, type Database Design. The array should now look like the one shown in the following code snippet:
"interests" : [ "Technology", "Gaming", "Web Design", "Software", "Database Design" ],
8. In the Document JSON Editor dialog box, click Validate. You should receive a message saying that the text contains valid JSON. Click OK to close the message box and return to the Document JSON Editor dialog box.
9. Click Update. The
interests array should now include the
Database Design value.
10. Leave the record in place on the Result tab in preparation for the next exercise.Next – Lesson 1, Exercise 4: Deleting a document from a collection