Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

In the following you get a short introduction to the Mongo Management Studio and will become familiar with the most important functions. The professional edition serves as the basis. In addition, we assume that you have access to a Mongo database. We use the zipcode collection as a template for our examples.

Installation

  • Download the Mongo Management Studio version appropiate for your system
  • Run the setup routine
  • Start the application

Switch language to english

  • Click the gear icon next to the button "Connect"
  • It will open the application settings
  • In the first checkbox, select "English" as language

Connect

  • Click on the button "Connect"
  • Enter the connection data for your Mongo database (for example localhost) into the field "Server Connection"
  • Click "Save and connect"

Create a demo database

  • Rightclick with the mouse onto the name of the Mongo server
  • Select "Add database" in the popup menu
  • Enter the database name "demo" and save it

Import the zipcode collection

  • Rightclick with the mouse button onto the demo database and select Import documents
  • Insert "zipcode" as name of the destination collection
  • Drag the "zips.json" file into the file upload field   
  • Click the "Import"-button

Querying data

  • Click in the database "demo" onto the collection "zipcode"
  • Switch to table view
  • Search for the city of CHESTER. For this enter following query in the search window
Codeblock
languagejs
themeEmacs
{city: 'CHESTER'}
  • Run the query by clicking on the "Run"-arrow-button or by the keyboard shortcut CMD + ENTER (MAC) or CTRL + ENTER (Windows / Linux)
  • Sort the results by the column "pop" (population)

Edit a document

  • Select a document and click the icon for "Edit document"
  • Change the field "city" to "CHESTER123"
  • Click "Save"

Create a document

  • Click the button "Add document"
  • Input the following record:
Codeblock
languagejs
themeEmacs
{city: 'Demo123city',pop: 999}
  • Click "Save"

Querying with regex

  • Search for all the cities containing 123
Codeblock
languagejs
themeEmacs
{city: /123/}

Deleting a document

  • Click on the icon for "Delete document(s)" for the document with the city "Demo123city"
  • Confirm the deletion security's query with Yes

Querying with aggregation framework

  • Select the aggregation framework in the toolbar
  • Enter the following query in the search window
Codeblock
languagejs
themeEmacs
[{
	$group: {
		_id : "$state",
    	totalPop : { $sum : "$pop" } 
	} 
},
{ 
	$match: {
		totalPop : { $gte : 10000000 } 
	} 
}] 
  • You get a result of all U.S. states with more than 10 million inhabitants

MongoDB Shell Query

  • Select the Mongo Shell Query in the toolbar
  • Enter the following query in the search window
Codeblock
languagejs
themeEmacs
db.zipcode.stats()
  • You get the statistics of the collection zipcode as result
  • Switch to the text view to see all the data at once

Copy a collection

  • Select in the toolbar the button "Collection" and then "Copy"
  • Select "Copy collection within the database
  • Enter "zipcode_copy" as name of the new collection
  • Click "Copy"