[clouchdb-cvs] CVS clouchdb/public_html

peddy peddy at common-lisp.net
Fri Dec 21 19:58:32 UTC 2007


Update of /project/clouchdb/cvsroot/clouchdb/public_html
In directory clnet:/tmp/cvs-serv32651/public_html

Modified Files:
	index.html 
Log Message:
Field name encoding updates, documentation reflecting those changes


--- /project/clouchdb/cvsroot/clouchdb/public_html/index.html	2007/12/20 23:44:40	1.9
+++ /project/clouchdb/cvsroot/clouchdb/public_html/index.html	2007/12/21 19:58:32	1.10
@@ -93,7 +93,7 @@
   <li><a href="http://www.cliki.net/Parenscript/">Parenscript</a></li>
   <li><a href="http://www.cliki.net/LIFT/">LIFT</a> testing framework</li>
   <li>An available <a href="http://couchdb.org">CouchDb</a> server,
-  current minimum supported version is 0.7, now tested on 7.2</li>
+  minimum supported version is 0.7, now tested on 7.3a</li>
 </ul>
 
 <h3>ASDF Install</h3>
@@ -502,10 +502,10 @@
 </p>
 <blockquote>
 <p>
-Executes the contained statements in the context of any of the
-specified connection values. Sets the host name, database name,
-protocol ("http" or "https") or port number of the CouchDb server to
-use in the expressions in the body.
+Executes the statements in body in the context of the specified
+connection values. Sets the host name, database name, protocol ("http"
+or "https") or port number of the CouchDb server to use in the
+expressions in the body.
 </p>
 <p>
 Example:
@@ -544,32 +544,33 @@
 <blockquote>
   <p>
     Document content takes the form of an associative list. The car of
-    each element of the associative list may be either a string or a
-    symbol. For example, each of the following calls to
-    (create-document) creates a document with a field which will be
-    named "name" in the database, but which will be :NAME (a keyword
-    symbol) when the documents are retrieved:
+    each associative list element represents the document field name,
+    the cdr contains the value. Field names are specified as keyword
+    symbols. The following example demonstrates the creation of a
+    simple document with two fields, :name and :agent, and with a
+    specified document ID:
   </p>
 
   <pre class="code">
-(create-document '((<b>:name</b> . "Max")) :id "keyword")
-(get-document "keyword")
-<b>=></b> ((:_ID . "keyword") (:_REV . "3674093994") (<b>:NAME</b> . "Max"))
-
-(create-document '((<b>name</b> . "Max")) :id "symbol")
-(get-document "symbol")
-<b>=></b> ((:_ID . "symbol") (:_REV . "3189074278") (<b>:NAME</b> . "Max"))
-
-(create-document '((<b>"name"</b> . "Max")) :id "string")
-(get-document "string")
-<b>=></b> ((:_ID . "string") (:_REV . "3730286488") (<b>:NAME</b> . "Max"))
-</pre>
+(create-document '((<b>:name</b> . "Max") (<b>:agent</b> . 86)) :id "agent86")
+(get-document "agent86")
+<b>=></b> ((:_ID . "agent86") (:_REV . "3674093994") (<b>:NAME</b> . "Max") (<b>:AGENT</b> . 86))
+  </pre>
+
+  <p>
+    As described above, clouchdb recognizes keyword symbols as field
+    names, this helps it distinguish .
+  </p>
 
   <p>
-    Field names in CouchDb are case sensitive. To specify a field name
-    that uses mixed case, you may either use a string value, or encode
-    the symbol appropriately. In the following example a single
-    document is created with two fields named, "name" and "Name":
+    Field names in CouchDb are case sensitive. Field names specified
+    with keyword symbols are normally stored as lower case characters
+    in CouchDb, however it is possible to use mixed case field names
+    as well.
+  </p>
+
+  <p>
+    To create a mixed case field name value you can use the 
   </p>
 
   <pre class="code">
@@ -650,6 +651,67 @@
 </p>
 
 <p>[Function]<br />
+<a name="sym-as-keyword-symbol"><b>as-keyword-symbol</b></a> string
+</p>
+<blockquote>
+<p>
+  Create a keyword symbol from a string, encode case information in
+  the result. This function translates Json field names from CouchDb
+  into the Lisp keyword symbols used in documents.
+</p>
+<p>
+Example:
+</p>
+<pre class="code">
+  ;; No case encoding
+  (as-keyword-symbol "normal")
+  <b>=></b> :NORMAL
+
+  ;; Upper case
+  (as-keyword-symbol "UPPER-CASE")
+  <b>=></b> :-U-P-P-E-R--C-A-S-E
+
+  ;; Mixed case
+  (as-keyword-symbol "MixedCase")
+  <b>=></b>:-MIXED-CASE
+</pre>
+<p>
+See (<a href="#sym-as-field-name-string">as-field-name-string</a>)
+</p>
+</blockquote>
+
+
+<p>[Function]<br />
+<a name="sym-as-field-name-string"><b>as-field-name-string</b></a> symbol
+</p>
+<blockquote>
+<p>
+  Convert a field name keyword symbol to a camelCase style
+  string. This function produces the field name in the format that
+  will be used and visible in CouchDb.
+</p>
+<p>
+Example:
+</p>
+<pre class="code">
+  ;; No case encoding
+  (as-field-name-string :normal)
+  <b>=></b> "normal"
+
+  ;; Upper case
+  (as-field-name-string :-u-p-p-e-r--c-a-s-e)
+  <b>=></b> "UPPER-CASE"
+
+  ;; Mixed case
+  (as-field-name-string :-Mixed-Case)
+  <b>=></b> "MixedCase"
+</pre>
+<p>
+  See (<a href="#sym-as-keyword-symbol">as-keyword-symbol</a>)
+</p>
+</blockquote>
+
+<p>[Function]<br />
 <a name="sym-create-document"><b>create-document</b></a> doc &key
 id
 </p>
@@ -1003,6 +1065,8 @@
 <blockquote>
 <p>
   <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-create-db">create-db</a> <br />
   <a href="#sym-create-document">create-document</a> <br />
   <a href="#sym-create-view">create-view</a> <br />
@@ -1048,18 +1112,6 @@
     support for attachments is not yet implemented in Clouchdb.
   </li>
 
-  <li><b>Document Encoding</b> Clouchdb currently
-    uses <a href="http://common-lisp.net/project/cl-json/">cl-json</a>
-    to encode and decode lisp data in Json, the native CouchDb
-    protocol data format. Unfortunately it is not always possible for
-    cl-json to discern the correct Json type from a given lisp value,
-    and this can result in unexpected document structure. For example,
-    it easily confuses associative list data with array data if the
-    first element's value in an associative list is a sequence. This
-    problem is being looked into, suggestions for resolutions to this
-    problem are welcome.
-  </li>
-
 </ul>
 
 




More information about the clouchdb-cvs mailing list