[clouchdb-cvs] CVS clouchdb/public_html
peddy
peddy at common-lisp.net
Sun Jul 13 22:25:43 UTC 2008
Update of /project/clouchdb/cvsroot/clouchdb/public_html
In directory clnet:/tmp/cvs-serv17445
Modified Files:
index.html
Log Message:
Add doc for missing bulk-document-update function
--- /project/clouchdb/cvsroot/clouchdb/public_html/index.html 2008/06/30 00:52:47 1.3
+++ /project/clouchdb/cvsroot/clouchdb/public_html/index.html 2008/07/13 22:25:39 1.4
@@ -627,52 +627,6 @@
</pre>
</blockquote>
-<p>[Special Variable]<br />
-<a name="sym-document-fetch-fn"><b>*document-fetch-fn*</b></a>
-</p>
-<blockquote>
-<p>
- A function which is called whenever a document is fetched from the
- database. The function takes one argument, the document, and returns
- the potentially modified document.
-</p>
-<p> See <a href="#sym-document-update-fn">*document-update-fn*</a></p>
-</blockquote>
-
-<p>[Special Variable]<br />
-<a name="sym-document-update-fn"><b>*document-update-fn*</b></a>
-</p>
-<blockquote>
-<p>
- A function which is called whenver a document is sent to the
- database via put-document, create-document or post-document
- functions. The function should take one parameter, which will be the
- document, and it should return one value, which should be the
- potentially modified document.
-</p>
-<pre class="code">
-;; Create a function that adds or updates a timestamp field in a
-;; document and returns the modified document
-(defun time-stamper (doc)
- (set-document-property doc :timestamp (get-universal-time)))
-
-;; Cause time-stamper to be invoked with each document as
-;; it's updated or created
-(setf *document-fetch-fn* #'time-stamper)
-
-;; Test the new time stamping feature
-(create-document '((:hello . "there")) :id "test")
-<b>=></b> ((:|ok| . T) (:|id| . "test") (:|rev| . "3721228336"))
-
-;; The new document should have been created with a timestamp,
-;; let's see if it worked:
-(get-document "test")
-<b>=></b> ((:|_id| . "test") (:|_rev| . "3721228336") (:TIMESTAMP . 3422649324)
- (:HELLO . "there"))
-</pre>
-<p> See <a href="#sym-document-fetch-fn">*document-fetch-fn*</a></p>
-</blockquote>
-
<p>[Function]<br />
<a name="sym-get-db-info"><b>get-db-info</b></a> &key db-name
</p>
@@ -1028,6 +982,93 @@
See (<a href="#sym-put-document">put-document</a>) (<a href="#sym-post-document">post-document</a>)</p>
</blockquote>
+
+<p>[Special Variable]<br />
+<a name="sym-document-fetch-fn"><b>*document-fetch-fn*</b></a>
+</p>
+<blockquote>
+<p>
+ A function which is called whenever a document is fetched from the
+ database. The function takes one argument, the document, and returns
+ the potentially modified document.
+</p>
+<p> See <a href="#sym-document-update-fn">*document-update-fn*</a></p>
+</blockquote>
+
+<p>[Special Variable]<br />
+<a name="sym-document-update-fn"><b>*document-update-fn*</b></a>
+</p>
+<blockquote>
+<p>
+ A function which is called whenver a document is sent to the
+ database via put-document, create-document or post-document
+ functions. The function should take one parameter, which will be the
+ document, and it should return one value, which should be the
+ potentially modified document.
+</p>
+<pre class="code">
+;; Create a function that adds or updates a timestamp field in a
+;; document and returns the modified document
+(defun time-stamper (doc)
+ (set-document-property doc :timestamp (get-universal-time)))
+
+;; Cause time-stamper to be invoked with each document as
+;; it's updated or created
+(setf *document-fetch-fn* #'time-stamper)
+
+;; Test the new time stamping feature
+(create-document '((:hello . "there")) :id "test")
+<b>=></b> ((:|ok| . T) (:|id| . "test") (:|rev| . "3721228336"))
+
+;; The new document should have been created with a timestamp,
+;; let's see if it worked:
+(get-document "test")
+<b>=></b> ((:|_id| . "test") (:|_rev| . "3721228336") (:TIMESTAMP . 3422649324)
+ (:HELLO . "there"))
+</pre>
+<p> See <a href="#sym-document-fetch-fn">*document-fetch-fn*</a></p>
+</blockquote>
+
+<p>[Function]<br />
+<a name="sym-bulk-document-update"><b>bulk-document-update</b></a> documents
+</p>
+<blockquote>
+<p>
+ Create or update multiple documents in a single request. This method
+ is far more efficient than individual document update or create
+ requests.
+</p>
+<p>
+ Document IDs are specified with the :|_id| name. If the identified
+ document does not yet exist it will be craeted with the :|_id|
+ value. If no :|_id| value is specified a new document with a CouchDb
+ ID will be created.
+</p>
+
+<p>
+Example:
+</p>
+<pre class="code">
+;; Invoke function with three documents. The first is a new document
+;; that will use a provided ID. The second is also a new document
+;; and because it does not specify an ID it will be assigned one by
+;; CouchDb. The third document already exists in the database, it is
+;; fetched with (get-document) and its :desc field is updated (or added).
+
+(bulk-document-update
+ (list
+ (set-document-property nil :|_id| "doc1" :desc "Create and speicfy ID")
+ (set-document-property nil :desc "Create using CouchDB ID")
+ (set-document-property (get-document "existing")
+ :desc "Update existing document")))
+
+<b>=></b> ((:|ok| . T) (:|new_revs| ((:|id| . "doc1") (:|rev| . "159627889"))
+ ((:|id| . "dc8376d34282c9aa7d8055b6f58e7345") (:|rev| . "261873756"))
+ ((:|id| . "existing") (:|rev| . "2956316650"))))
+</pre>
+</blockquote>
+
+
<p>[Function]<br />
<a name="sym-delete-document"><b>delete-document</b></a> &key document
id revision if-missing</p>
@@ -1698,6 +1739,7 @@
<a href="#sym-ad-hoc-view">ad-hoc-view</a> <br />
<a href="#sym-as-field-name-string">as-field-name-string</a><br />
<a href="#sym-as-keyword-symbol">as-keyword-symbol</a><br />
+ <a href="#sym-bulk-document-update">bulk-document-update</a><br />
<a href="#sym-compact-db">compact-db</a> <br />
<a href="#sym-create-db">create-db</a> <br />
<a href="#sym-create-document">create-document</a> <br />
More information about the clouchdb-cvs
mailing list