Im Folgenden erhalten Sie einen kurzen Einstieg in das Mongo Management Studio und werden mit den wichtigsten Funktionen vertraut gemacht. Als Basis dient hierbei die lokale Version. Außerdem gehen wir davon aus, dass Sie Zugriff auf eine Mongo Datenbank haben. Wir verwenden die Collection zipcode als VorlageIn 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 required version of Mongo Management Studio
- Run the setup routine
- Start the application
Setting the English Switch language to english
- Click the gear icon next to the button "Connect"
- It will open the application settings
- In the first selection box checkbox, select "English" as language
Connect
- Click on the button "Connect"
- Enter in the field "Server Connection" the connection data for your Mongo database (for example localhost)example localhost) into the field "Server Connection"
- Click "Save and connect"
Create a demo database
- Click Rightclick with the right mouse button on onto the name of the Mongo server
- Select "Add database" in the popup menu
- Enter the database name "demo" and save it
Import of the zipcode collection
- Download the collection zipcode (http://media.mongodb.org/zips.json)
- Click Rightclick with the right mouse button on onto the demo database and select Import documents
- Insert "zipcode" as name of the destination collection
- Drag the "zips.json" file in to the file upload field for the file upload
- Click the "Import"-button
...
- Click in the database "demo" on onto the collection "zipcode"
- Switch to table view
- Search for the city of CHESTER. For this enter following query in the search window
Codeblock | ||||||
---|---|---|---|---|---|---|
| ||||||
city: 'CHESTER' |
- Run the query by clicking on the "Run"-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 | ||||||
---|---|---|---|---|---|---|
| ||||||
{city: 'Demo123city',pop: 999} |
- Click "Save"
Querying with regex
- Search for all the cities containing 123
Codeblock | ||||||
---|---|---|---|---|---|---|
| ||||||
city: /123/ |
Löschen von Datensätzen
...
Deleting a document
- Click on the icon for "Delete document(s)" for the document with the city "Demo123city"
- Bestätigen Sie die Löschen Sicherheit's Abfrage mit Ja
Aggregation Abfrage
- Wählen Sie in der Symbolleiste Confirm the deletion security's query with Yes
Querying with aggregation framework (not available in the Community Edition)
- Select "A" (Aggregation) für eine Aggregation Framework Abfrage
- Geben Sie im Suchfester folgende Abfrage ein
...
theme | Emacs |
---|---|
language | js |
- aggregation) in the toolbar for an aggregation Framework query
- Enter the following query in the search window
Codeblock | ||||
---|---|---|---|---|
| ||||
{ $group: { _id : "$state", totalPop : { $sum : "$pop" } } }, { $match: { totalPop : { $gte : 10000000 } } } |
- Man erhält als Ergebnis alle US Bundesstaaten mit mehr als 10 Millionen Einwohnern
Konsolen Abfrage
- Wählen Sie in der Symbolleiste You get a result of all U.S. states with more than 10 million inhabitants
Querying via console mode
- Select "C" (Console) für eine MongoDB Konsolen Abfrage
- Geben Sie im Suchfester folgende Abfrage ein
...
- console) in the toolbar for the console mode
- Enter the following query in the search window
Codeblock | ||||||
---|---|---|---|---|---|---|
| ||||||
db.zipcode.stats() |
- Man erhält als Ergebnis die Statistiken der Collection zipcode
- Wechseln Sie in die Textansicht, um alle Daten auf einmal zu sehen
Kopieren der Collection
- Wählen Sie in der Symbolleiste den Button "Collection" und dann "Kopieren"
- Wählen Sie "Collection innerhalb der Datenbank kopieren" aus
- Geben Sie als Namen "zipcode_copy" ein
- Klicken Sie "KopierenYou 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"