Exercise 3: Exporting document data to a new collection

In this exercise, you’ll create the scottish_info database and then add the scottish_pubs collection to the database. Next, you’ll export the query results you generated in Exercise 2 to the new collection.

To export the documents

1. In the Connection Tree, right-click the connection (top-level node) and click Add Database.

2. In the Add Database dialog box, type scottish_info in the Database Name text box, and then click OK.

scottish info

Studio 3T adds the scottish_info database node to the Connection Tree.

3. Right-click the scottish_info database node and click Add Collection.

scottish add collection

4. In the Add New Collection dialog box, type scottish_pubs in the Collection Name text box, and then click Create.

new collection

5. Return to the british_pubs collection tab and click Export on the toolbar to launch the Export Wizard.

export tab

6. On the Export source page, select the Current Query Result option and then click Next.

export current tab

7. On the Select the export format page, select To another collection and then click Next.

export to another collection

8. On the Choose target collection page, click on Click here to connect to a server. This will open the Connection Manager dialog.

connection to server

9. Select the target MongoDB connection from the list – which in our case is mongo1 – and then click Connect.

10. On the Choose target collection page, navigate to the scottish_pubs collection in the scottish_info database, and then click Finish.

Choose target collection

11. This will open the Export unit #1 – To another collection tab. Review the export details and then click on Execute in the toolbar.

Export unit one

12. Go to the scottish_pubs collection tab and click the Refresh button (Refresh tab)on the Result tab toolbar.

scottish result tab

The Result tab should now display the first 50 imported documents.

13. In the Connection Tree, right-click the pubs database node and click Drop Database.

pubs drop databse

14. In the Drop Database dialog box, click Drop Database.

15. Repeat the previous two steps to drop the scottish_info database.

16. Close Studio 3T.

You’ve finished the exercise! Click on Test your skills to review what you’ve learned.

Log in

Log in to your Studio 3T Academy account

Forgot password?

Don't have an account yet? Sign up
Sign up

Start learning MongoDB today. All fields are mandatory.

By signing up for a course, you agree to the 3T Software Labs Privacy Policy.


Already have an account? Log in