Commenting code, adding docs.
This commit is contained in:
parent
611d9666bd
commit
16d02800d3
2 changed files with 35 additions and 0 deletions
|
|
@ -33,6 +33,8 @@ If you have more than one database to connect, use monger.core/connect and monge
|
||||||
nonlocal-mongodb-connection (monger.core/connect :host "my-mongo-server.local")
|
nonlocal-mongodb-connection (monger.core/connect :host "my-mongo-server.local")
|
||||||
my-second-database (monger.core/get-db "my-second-database-name") ])
|
my-second-database (monger.core/get-db "my-second-database-name") ])
|
||||||
|
|
||||||
|
TODO: How to authenticate
|
||||||
|
|
||||||
So, now you have 2 connections and 2 databases, you can manipulate them independently.
|
So, now you have 2 connections and 2 databases, you can manipulate them independently.
|
||||||
|
|
||||||
# Working with collections
|
# Working with collections
|
||||||
|
|
@ -57,6 +59,8 @@ If you know how to use MongoDB console, you already know how to write Monger que
|
||||||
## Querying collections
|
## Querying collections
|
||||||
|
|
||||||
### find
|
### find
|
||||||
|
|
||||||
|
|
||||||
### find-one
|
### find-one
|
||||||
### find-by-id
|
### find-by-id
|
||||||
### count
|
### count
|
||||||
|
|
@ -66,6 +70,16 @@ If you know how to use MongoDB console, you already know how to write Monger que
|
||||||
|
|
||||||
## Inserting records
|
## Inserting records
|
||||||
|
|
||||||
|
## Write Concerns
|
||||||
|
|
||||||
|
Every write-related operation supports passing WriteConcern. WriteConcern specifies how much safety you want with for a given operation.
|
||||||
|
|
||||||
|
You can find detailed, elaborate representation for WriteConcerns
|
||||||
|
* here http://www.littlelostmanuals.com/2011/11/overview-of-basic-mongodb-java-write.html
|
||||||
|
* and here http://api.mongodb.org/java/current/com/mongodb/WriteConcern.html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Single
|
### Single
|
||||||
### Batch
|
### Batch
|
||||||
|
|
||||||
|
|
@ -75,6 +89,9 @@ If you know how to use MongoDB console, you already know how to write Monger que
|
||||||
|
|
||||||
### Atomic modifiers
|
### Atomic modifiers
|
||||||
|
|
||||||
|
Atomic modifiers are simple operations on a single document that are commited to database atomically.
|
||||||
|
|
||||||
|
|
||||||
## save
|
## save
|
||||||
|
|
||||||
# Indexing
|
# Indexing
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,12 @@
|
||||||
|
|
||||||
|
|
||||||
(defn exists?
|
(defn exists?
|
||||||
|
"Checks weather collection with certain name exists.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
|
||||||
|
(monger.collection/exists? \"coll\")
|
||||||
|
"
|
||||||
[^String collection]
|
[^String collection]
|
||||||
(.collectionExists monger.core/*mongodb-database* collection))
|
(.collectionExists monger.core/*mongodb-database* collection))
|
||||||
|
|
||||||
|
|
@ -323,11 +329,23 @@
|
||||||
(.createCollection monger.core/*mongodb-database* collection (to-db-object options)))
|
(.createCollection monger.core/*mongodb-database* collection (to-db-object options)))
|
||||||
|
|
||||||
(defn drop
|
(defn drop
|
||||||
|
"Deletes collection from database.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
|
||||||
|
(monger.collection/drop \"collection-to-drop\")
|
||||||
|
"
|
||||||
[^String collection]
|
[^String collection]
|
||||||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
||||||
(.drop coll)))
|
(.drop coll)))
|
||||||
|
|
||||||
(defn rename
|
(defn rename
|
||||||
|
"Renames collection.
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
|
||||||
|
(monger.collection/rename \"old_name\" \"new_name\")
|
||||||
|
"
|
||||||
([^String from, ^String to]
|
([^String from, ^String to]
|
||||||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* from)]
|
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* from)]
|
||||||
(.rename coll to)))
|
(.rename coll to)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue