couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Cl-Couch" by RyszardSzopa
Date Fri, 13 Jun 2008 00:49:31 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by RyszardSzopa:
http://wiki.apache.org/couchdb/Cl-Couch

------------------------------------------------------------------------------
  
  This sets {{{*COUCHDB-SERVER*}}} to the default http://localhost:5984. This isn't really
necessary, but allows us to omit the server argument when we make requests.
  
- === R ===
+ === COUCH-REQUEST ===
  
- {{{R}}} takes specifiers for a request to a CouchDB database and returns a Lisp object.
HTTP PUT and POST requests with {{{R}}} take Lisp objects as well, thus enabling the programmer
to black-box the JSON layer completely.
+ {{{COUCH-REQUEST}}} takes specifiers for a request to a CouchDB database and returns a Lisp
object. HTTP PUT and POST requests with {{{COUCH-REQUEST}}} take Lisp objects as well, thus
enabling the programmer to black-box the JSON layer completely.
  
  ==== Examples ====
  
- Using {{{R}}} to make a GET request to {{{http://localhost:5984/blog/150fedd5d14f0771eb5e44d071a1df5d}}}:
+ Using {{{COUCH-REQUEST}}} to make a GET request to {{{http://localhost:5984/blog/150fedd5d14f0771eb5e44d071a1df5d}}}:
  
  {{{
- COUCHDB-CLIENT> (r :get (blog "150fedd5d14f0771eb5e44d071a1df5d"))
+ COUCHDB-CLIENT> (couch-request :get (blog "150fedd5d14f0771eb5e44d071a1df5d"))
  ((:_ID . "150fedd5d14f0771eb5e44d071a1df5d") (:_REV . "253381451")
   (:AUTHOR . "foo") (:BODY . "Zażółć") (:POST . "third") (:TYPE . "comment")
   (:N . 66))
  }}}
  
- Using {{{R}}} to make a GET request to {{{http://localhost:5984/blog/_all_docs?count=2}}}:
+ Using {{{COUCH-REQUEST}}} to make a GET request to {{{http://localhost:5984/blog/_all_docs?count=2}}}:
  
  {{{
- COUCHDB-CLIENT> (r :get (blog _all_docs :count 2))
+ COUCHDB-CLIENT> (couch-request :get (blog _all_docs :count 2))
  ((:TOTAL-ROWS . 48) (:OFFSET . 0)
   (:ROWS
    ((:ID . "06672346ffc093ce68a07692a5f12db5")
@@ -64, +64 @@

     (:KEY . "14328cab564dfec5eac0ff0a44d2083d") (:VALUE (:REV . "1258191009")))))
  }}}
  
- === R* ===
+ === COUCH-REQUEST* ===
  
- {{{R*}}} is the functional equivalent to the macro {{{R}}}.
+ {{{COUCH-REQUEST*}}} is the functional equivalent to the macro {{{COUCH-REQUEST}}}.
  
  === @ ===
  
@@ -175, +175 @@

  		      (:_id :initform (lambda (doc) (url-encode (@ doc :title))))
  		      (:body :validator #'stringp))
  		   (:default-db 'blog))
- #<STANDARD-METHOD MAKE ((EQL BLOG-POST)) {BEB6679}>
+ #<STANDARD-METHOD MAKE-DOC ((EQL BLOG-POST)) {BEB6679}>
  }}}
  
  "Attributes" are like slots, except identified by a keyword. Attributes can have a {{{:VALIDATOR}}}
and {{{:INITFORM}}} and {{{:DOCUMENTATION}}} attribute-options (which are liks slot-options
for CLOS objects).
@@ -186, +186 @@

  
  === Making Docs ===
  
- Use the function {{{MAKE}}} to make {{{DOC}}}s. {{{MAKE}}} is something like [http://www.lisp.org/HyperSpec/Body/stagenfun_make-instance.html
MAKE-INSTANCE].
+ Use the function {{{MAKE-DOC}}} to make {{{DOC}}}s. {{{MAKE-DOC}}} is something like [http://www.lisp.org/HyperSpec/Body/stagenfun_make-instance.html
MAKE-INSTANCE].
  
  {{{
- COUCHDB-OBJECTS> (make 'blog-post :author "Kuba" :title "O czym dziś napisać" :body
"Foo")
+ COUCHDB-OBJECTS> (make-doc 'blog-post :author "Kuba" :title "O czym dziś napisać" :body
"Foo")
  #<doc(NIL) :_ID "o_czym_dzis_napisac" :BODY "Foo" :TITLE "O czym dziś napisać" :AUTHOR
"Kuba" :TYPE "BLOG-POST">
  }}}
  
@@ -198, +198 @@

  You can call {{{@}}} on docs to get the value of an attribute, exactly as you would call
{{{@}}} on an alist.
  
  {{{
- COUCHDB-OBJECTS> (let ((doc (make 'blog-post :author "Kuba" :title "O czym dziś napisać"
:body "Foo")))
+ COUCHDB-OBJECTS> (let ((doc (make-doc 'blog-post :author "Kuba" :title "O czym dziś
napisać" :body "Foo")))
  		   (@ doc :title))
  "O czym dziś napisać"
  }}}
@@ -208, +208 @@

  We can call {{{make-and-save}}} to create a document and save it in the database:
  
  {{{
- COUCHDB-OBJECTS> (make-and-save 'blog-post :author "Kuba" :title "Zażółć gęślą
jaźń" :body "foobar") ;we'll get the rev in return
+ COUCHDB-OBJECTS> (make-doc-and-save 'blog-post :author "Kuba" :title "Zażółć gęślą
jaźń" :body "foobar") ;we'll get the rev in return
  "2591270477"
  }}}
  
  Note: if an object is invalid, it won't be saved:
  {{{
- COUCHDB-OBJECTS> (make-and-save 'blog-post :author "Kuba" :title "Zażółć gęślą
jaźń")
+ COUCHDB-OBJECTS> (make-doc-and-save 'blog-post :author "Kuba" :title "Zażółć gęślą
jaźń")
  The document #<doc(NIL) :_ID "zazolc_gesla_jazn" :TITLE "Zażółć gęślą jaźń"
:AUTHOR "Kuba" :TYPE "BLOG-POST"> is invalid. Reason: attribute
  		      :BODY with value NIL didn't validate using #<FUNCTION STRINGP>
     [Condition of type VALIDATOR-FAILED]

Mime
View raw message