Use and recommend sorted maps for commands
This commit is contained in:
parent
1d179d9185
commit
1a351cff88
2 changed files with 11 additions and 57 deletions
|
|
@ -27,13 +27,13 @@
|
|||
([collection]
|
||||
(collection-stats monger.core/*mongodb-database* collection))
|
||||
([^DB database collection]
|
||||
(monger.core/command database { :collstats collection })))
|
||||
(monger.core/command database {:collstats collection})))
|
||||
|
||||
(defn db-stats
|
||||
([]
|
||||
(db-stats monger.core/*mongodb-database*))
|
||||
([^DB database]
|
||||
(monger.core/command database {:dbStats 1 })))
|
||||
(monger.core/command database {:dbStats 1})))
|
||||
|
||||
|
||||
(defn reindex-collection
|
||||
|
|
@ -41,21 +41,21 @@
|
|||
([^String collection]
|
||||
(reindex-collection monger.core/*mongodb-database* collection))
|
||||
([^DB database ^String collection]
|
||||
(monger.core/command database { :reIndex collection })))
|
||||
(monger.core/command database {:reIndex collection})))
|
||||
|
||||
(defn rename-collection
|
||||
"Changes the name of an existing collection using the renameCollection command"
|
||||
([^String from ^String to]
|
||||
(reindex-collection monger.core/*mongodb-database* from to))
|
||||
([^DB database ^String from ^String to]
|
||||
(monger.core/command database { :renameCollection from :to to })))
|
||||
(monger.core/command database (sorted-map :renameCollection from :to to))))
|
||||
|
||||
(defn convert-to-capped
|
||||
"Converts an existing, non-capped collection to a capped collection using the convertToCapped command"
|
||||
([^String collection ^long size]
|
||||
(convert-to-capped monger.core/*mongodb-database* collection size))
|
||||
([^DB database ^String collection ^long size]
|
||||
(monger.core/command database {:convertToCapped collection :size size})))
|
||||
(monger.core/command database (sorted-map :convertToCapped collection :size size))))
|
||||
|
||||
(defn empty-capped
|
||||
"Removes all documents from a capped collection using the emptycapped command"
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
([]
|
||||
(server-status monger.core/*mongodb-database*))
|
||||
([^DB database]
|
||||
(monger.core/command database {:serverStatus 1 })))
|
||||
(monger.core/command database {:serverStatus 1})))
|
||||
|
||||
|
||||
(defn top
|
||||
|
|
|
|||
|
|
@ -230,59 +230,13 @@
|
|||
|
||||
|
||||
(defn ^com.mongodb.CommandResult command
|
||||
"Runs a database command (please check MongoDB documentation for the complete list of commands). Some common commands
|
||||
are:
|
||||
"Runs a database command (please check MongoDB documentation for the complete list of commands).
|
||||
|
||||
{ :buildinfo 1 } returns version number and build information about the current MongoDB server, should be executed via admin DB.
|
||||
Ordering of keys in the command document may matter. Please use sorted maps instead of map literals, for example:
|
||||
(sorted-map geoNear \"bars\" :near 50 :test 430 :num 10)
|
||||
|
||||
{ :collstats collection-name [ :scale scale ] } returns stats about given collection.
|
||||
|
||||
{ :dbStats 1 } returns the stats of current database
|
||||
|
||||
{ :dropDatabase 1 } deletes the current database
|
||||
|
||||
{ :findAndModify find-and-modify-config } runs find, modify and return for the given query.
|
||||
Takes :query, :sory, :remove, :update, :new, :fields and :upsert arguments.
|
||||
Please refer MongoDB documentation for details. http://www.mongodb.org/display/DOCS/findAndModify+Command
|
||||
|
||||
{ :fsync config } performs a full fsync, that flushes all pending writes to database, provides an optional write lock that will make
|
||||
backups easier.
|
||||
Please refer MongoDB documentation for details :http://www.mongodb.org/display/DOCS/fsync+Command
|
||||
|
||||
{ :getLastError 1 } returns the status of the last operation on current connection.
|
||||
|
||||
{ :group group-config } performs grouping aggregation, docs and support for grouping are TBD in Monger.
|
||||
|
||||
{ :listCommands 1 } displays the list of available commands.
|
||||
|
||||
{ :profile new-profile-level } sets the database profiler to profile level N.
|
||||
|
||||
{ :reIndex coll } performs re-index on a given collection.
|
||||
|
||||
{ :renameCollection old-name :to new-name } renames collection from old-name to new-name
|
||||
|
||||
{ :repairDatabase 1 } repair and compact the current database (may be very time-consuming, depending on DB size)
|
||||
|
||||
Replica set commands
|
||||
{ :isMaster 1 } checks if this server is a master server.
|
||||
{ :replSetGetStatus 1 } get the status of a replica set.
|
||||
{ :replSetInitiate replica-config } initiate a replica set with given config.
|
||||
{ :replSetReconfig replica-config } set a given config for replica set.
|
||||
{ :replSetStepDown seconds } manually tell a member to step down as primary. It will become primary again after specified amount of seconds.
|
||||
{ :replSetFreeze seconds } freeze state of member, call with 0 to unfreeze.
|
||||
{ :resync 1 } start a full resync of a replica slave
|
||||
For more information, please refer Mongodb Replica Set Command guide: http://www.mongodb.org/display/DOCS/Replica+Set+Commands
|
||||
|
||||
{ :serverStatus 1 } gets administrative statistics about the server.
|
||||
|
||||
{ :shutdown 1 } shuts the MongoDB server down.
|
||||
|
||||
{ :top 1 } get a breakdown of usage by collection.
|
||||
|
||||
{ :validate namespace-name } validate the namespace (collection or index). May be very time-consuming, depending on DB size.
|
||||
|
||||
For :distinct, :count, :drop, :dropIndexes, :mapReduce we suggest to use monger/collection #distinct, #count, #drop, #dropIndexes, :mapReduce respectively.
|
||||
"
|
||||
For commonly used commands (distinct, count, map/reduce, etc), use monger/command and monger/collection functions such as
|
||||
/distinct, /count, /drop, /dropIndexes, and /mapReduce respectively."
|
||||
([^Map cmd]
|
||||
(.command ^DB *mongodb-database* ^DBObject (to-db-object cmd)))
|
||||
([^DB database ^Map cmd]
|
||||
|
|
|
|||
Loading…
Reference in a new issue