From 16d02800d3643728b8fa6cf0a76340a8a5610802 Mon Sep 17 00:00:00 2001 From: Oleksandr Petrov Date: Sat, 3 Dec 2011 18:39:17 +0100 Subject: [PATCH] Commenting code, adding docs. --- docs/querying.md | 17 +++++++++++++++++ src/monger/collection.clj | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/docs/querying.md b/docs/querying.md index 5755acf..4b5bc04 100644 --- a/docs/querying.md +++ b/docs/querying.md @@ -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") 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. # 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 ### find + + ### find-one ### find-by-id ### count @@ -66,6 +70,16 @@ If you know how to use MongoDB console, you already know how to write Monger que ## 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 ### 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 are simple operations on a single document that are commited to database atomically. + + ## save # Indexing diff --git a/src/monger/collection.clj b/src/monger/collection.clj index f28d92a..6c0421c 100644 --- a/src/monger/collection.clj +++ b/src/monger/collection.clj @@ -315,6 +315,12 @@ (defn exists? + "Checks weather collection with certain name exists. + + EXAMPLE: + + (monger.collection/exists? \"coll\") + " [^String collection] (.collectionExists monger.core/*mongodb-database* collection)) @@ -323,11 +329,23 @@ (.createCollection monger.core/*mongodb-database* collection (to-db-object options))) (defn drop + "Deletes collection from database. + + EXAMPLE: + + (monger.collection/drop \"collection-to-drop\") + " [^String collection] (let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)] (.drop coll))) (defn rename + "Renames collection. + + EXAMPLE: + + (monger.collection/rename \"old_name\" \"new_name\") + " ([^String from, ^String to] (let [^DBCollection coll (.getCollection monger.core/*mongodb-database* from)] (.rename coll to)))