couchdb

Introduction

Apache CouchDB is a document-oriented database that can be queried and indexed in a MapReduce fashion using JavaScript. CouchDB also offers incremental replication with bi-directional conflict detection and resolution.

Requirements

Documentation

As said above a CouchDB server will use the JSON format for encoding responses. The json egg manages the marshalling and unmarshalling. See there for the correct type conversions. As a convenience function json-ref is provided by this egg.

Querys to the database are encoded in URIs. Depending on the setup of the CouchDB server username and password may have to be encoded in the URI. This applys to database creation / deletion mostly.

Error handling

All procedures return #f on error. The last error is provided with the utility procedure last-error.

CouchDB connection procedures

For identifying connections a connection record has to be created first.

make-connection

[procedure](make-connection DATABASE-STRING URI-STRING)

Creates a connection record for the desired DATABASE-STRING on the CouchDB located at the specified URI string.

Database handling

Creates a database as specified in the connection record connection. Use (make-connection database-string couchdb-uri-string) to create a connection object.

Returns #t or #f. Verbose error message can be retrieved with ''last-error'.

[procedure](delete-database connection)

Deletes the database as specified in the connection record connection. Use (make-connection database-string couchdb-uri-string) to create a connection object.

Returns #t or #f. Verbose error message can be retrieved with ''last-error'.

[procedure](get-database-info connection)

Returns the database information for a given connection record. Use (make-connection database-string couchdb-uri-string) to create a connection record.

Document handling

The central entity in a CouchDB is a so called document. A CouchDB document is an object that consists of named fields. Field values may be strings, numbers, dates, or even ordered lists and associative maps, all encoded in JSON.

However there are at least two mandatory fields in each document:

id

unique id within the database

rev

revision of that document

Document datatype

[procedure](make-document id revision #!optional (body '#()))

The couchdb uses a record to represent the contents of a document. The mandatory elements have distinct slots whereas the rest of the fiels is accessible in a vector called body.

Author

License

Apache CouchDB client library
Copyright (C) 2009 Moritz Heidkamp
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can find a copy of the GNU Lesser General Public License at
http://www.gnu.org/licenses/