Versionen im Vergleich

Schlüssel

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

Mongo shell commands can be executed in console modeThe inputs are directly forwarded to the native mongo shell and are not formatted or modified by the application.

 

With v1
Warnung
Info

This is a new feature since version 1.2.0

has been added a new Feature

! The former console mode

[

(C

]

) is now moved to server side script mode

[

(S

]. The new console mode [ C ] is now the original client side mongo shell.

 

 

Client side shell

In the mongo console mode [ C ] they all commands supported, as such in the original mongo shell.

).

Tipp

Here you will find a the documentation of the Mongo shell commands: http://docs.mongodb.org/manual/core/crud-introduction/

 

...

...

Codeblock

...

 

Codeblock
themeEmacs
languagejs
linenumberstrue
// Returns all documents
db.zipcode.find();
 
// Returns all cities name and sorted by them
db.zipcode.find({}, {city: 1}).sort({city: 1})
 
// Create a new zipcode document
db.zipcode.insert({_id: '99999', city: 'LEIPZIG', pop: 520838, state: 'SN'})
 
// Analyze the find-query
db.zipcode.find().explain()
 
// Show the statistics of the collection
db.zipcode.stats();
info
Warnung

There is no pager in console mode. Therefore, all records are loaded for each query. Because this can be a very large amount of data in certain circumstances, the results are limited to 100 documents. It is recommended to use the skip () and limit () functions.

Using

 

...

 

You can enter multiple commands that have to be included in a function and the result must be returned with the return statement.

Codeblock
themeEmacs
languagejs
function () {
	var stats = db.zipcode.stats();
	var index = db.zipcode.getIndexes();
	return {
		stats: stats,
		indexInformation: index
	};
}

...