From couchdb-commits-returnrachel17@example.net Wed Mar 26 20:19:09 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 37722 invoked from network); 26 Mar 2008 20:19:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 20:19:09 -0000 Received: (qmail 78123 invoked by uid 500); 26 Mar 2008 20:19:06 -0000 Delivered-To: rachel17@example.net Received: (qmail 78083 invoked by uid 500); 26 Mar 2008 20:19:06 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Delivered-To: moderator for rachel17@example.net Received: (qmail 69223 invoked by uid 99); 26 Mar 2008 20:13:16 -0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 20:12:45 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "QuickOverview" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/QuickOverview The comment on the change is: Copied from original CouchDB wiki New page: = Quick Overview = A quick overview to CouchDB, it's philosophy, architecture, strengths and weaknesses. == What CouchDB is == * A document database server, accessible via a RESTful [http://json.org/ JSON] API. * Ad-hoc and schema-free with a flat address space. * Distributed, featuring robust, incremental replication with bi-directional conflict detection and management. * Query-able and index-able, featuring a table oriented reporting engine that uses Javascript as a query language. == What CouchDB is not == * A relational database. * A replacement for relational databases. * An object-oriented database. More specifically, CouchDB is not meant to function as a seamless persistence layer for an OO programming language. == What's a Document? == A CouchDB document is an object that consists of named fields. Field values are lists that may contain strings, numbers and dates. An example of a document would be a blog post: {{{ Subject: "I like Plankton" Author: "Rusty" PostedDate: "5/23/2006" Tags: "plankton" "baseball" "decisions" Body: "I decided today that I don't like baseball. I like plankton." }}} In the above example document, Subject is a field that contains a single string value "I like plankton". Tags is a field with values "plankton", "baseball" and "decisions". A Couch database is a flat collection of these documents. Each document is identified by a unique ID, a DocID. Each document has one (and only one) DocID, and that DocID must be unique. Two documents with the same ID in different replicas of the same database are considered to be instances of the same document. By default, DocIDs are UUIDs (a randomly generated 128 bit number, example: F81D4FAE7DEC11D0A76500A0C91E6BF6), but ''any string'' can be a document ID. Examples of valid DocIDs: {{{ F81D4FAE7DEC11D0A76500A0C91E6BF6 Order_no_57 Global_Config_Settings http://damienkatz.net/2006/04/error_code_vs_e.html Whatchootalkinboutwillis }}} == Views == To address this problem of adding structure back to semi-structured data, CouchDB integrates a view model using Javascript for description. Views are the method of aggregating and reporting on the documents in a database, and are built on-demand to aggregate, join and report on database documents. Views are built dynamically and don't affect the underlying document, you can have as many different view representations of the same data as you like. == Distributed == CouchDB is a peer based distributed database system. Any number of CouchDB hosts (servers and offline-clients) can have independent "replica copies" of the same database, where applications have full database interactivity (query, add, edit, delete). When back online or on a schedule, database changes are replicated bi-directionally. CouchDB has built-in conflict detection and management and the replication process is incremental and fast, copying only documents and individual fields changed since the previous replication. Most applications require no special planning to take advantage of distributed updates and replication. == Why would I ever want to use CouchDB? == === Document Oriented === CouchDB is designed for document-oriented applications. A typical real-world document oriented activity, if it weren't computerized, would consist mostly of physical paper documents. These documents would need to get sent around, edited, photocopied, approved, denied, pinned to the wall, filed away, buried in soft peat for six months, etc. They could be simple yellow sticky notes or 10,000 page legal documents. Not all document-oriented applications have real world counterparts. Some examples of document-oriented applications: * CRM * Contact Address/Phone Book * Forum/Discussion * Bug Tracking * Document Collaboration/Wiki * Customer Call Tracking * Expense Reporting * To-Dos * Time Sheets * E-mail * Help/Reference Desk === Not SQL === Unlike SQL databases which are designed to store and report on highly structured, interrelated data, CouchDB is designed to store and report on large amounts of semi-structured, document oriented data. CouchDB greatly simplifies the development of document oriented applications, which make up the bulk of collaborative web applications. In an SQL database, as needs evolve the schema and storage of the existing data must be updated. This often causes problems as new needs arise that simply weren't anticipated in the initial database designs, and makes distributed "upgrades" a problem for every host that needs to go through a schema update. With CouchDB, no schema is enforced, so new document types with new meaning can be safely added alongside the old. The view engine is designed to easily handle new document types and disparate but similar documents. === Distributed === CouchDB is built from the start with a consistent vision of a distributed document database system. Unlike cumbersome attempts to bolt distributed features on top of the same legacy models and databases, it is the result of careful ground-up design, engineering and integration. The document, view, security and replication models and the efficient and robust disk layout are designed to work together for a reliable, easy to use and efficient system. From couchdb-commits-returnrachel17@example.net Wed Mar 26 20:29:37 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 41669 invoked from network); 26 Mar 2008 20:29:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 20:29:35 -0000 Received: (qmail 98248 invoked by uid 500); 26 Mar 2008 20:29:34 -0000 Delivered-To: rachel17@example.net Received: (qmail 98228 invoked by uid 500); 26 Mar 2008 20:29:34 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 98217 invoked by uid 99); 26 Mar 2008 20:29:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 13:29:34 -0700 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 20:28:53 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 9D509D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 20:29:04 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 20:29:04 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "Faq" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/Faq The comment on the change is: Copied from original CouchDB wiki New page: = FAQ = A handy FAQ for all your CouchDB related questions. If you have a question not yet answered in this FAQ please hit the edit button and add your question at the end. Check back in a few days, someone may have provided an answer. == What is CouchDB? == CouchDB is a document-oriented, Non-Relational Database Management Server (NRDBMS). The [wiki:QuickOverview Quick Overview] has a high level overview of the CouchDB system. == What is the Status of CouchDB? == Alpha Release. It is still missing important features, but it's usable enough for testing. == What Does Couch Mean? == It's an acronym, Cluster Of Unreliable Commodity Hardware. This is a statement of Couch's long term goals of massive scalablility and high reliability on fault-prone hardware. The distributed nature and flat address space of the database will enable node partitioning for storage scalabilty (with a map/reduce style query facility) and clustering for reliability and fault tolerance. == What Language is CouchDB Written in? == Erlang, a concurrent, functional programming language with an emphasis on fault tolerance. Early work on CouchDB was started in C but was replaced by Erlang OTP platform. Erlang has so far proven an excellent match for this project. CouchDB uses Mozilla's Spidermonkey Javscript library which is written in C. == What Platforms are Supported? == Most POSIX systems, this includes GNU/Linux and OS X. Windows is not officially supported but it should work, please let us know. == What is the License? == Apache 2. == How Much Stuff can I Store in CouchDB? == With node partitioning, virtually unlimited. For a single database instance, the practical scaling limits aren't yet known. == How Do I Do Sequences? == Or, where is my AUTO_INCREMENT?! With replication sequences are hard to realize. Sequences are often used to ensure unique identifiers for each row in a database table. CouchDB generates unique ids from its own and you can specify your own as well, so you don't really need a sequence here. If you use a sequence for something else, you might find a way to express in CouchDB in another way. == How Do I Configure Replication? == To replicate a database from the CouchDB Erlang console (try ''ccouchdb -i''), type: {{{ couch_rep:replicate("local_database_name_a", "local_database_name_b"). }}} You can also specify a HTTP URL to a remote database: {{{ couch_rep:replicate( "local_database_name_a" "http://remoteserver:8888/remote_database_name_b/"). }}} Either or both databases can be remote: {{{ couch_rep:replicate( "http://remoteserver:8888/remote_database_name_a/", "http://remoteserver:8888/remote_database_name_b/"). }}} == How Fast are CouchDB Views? == It would be quite hard to give out any numbers that make much sense. From the architecture point of view, a view on a table is much like a (multi-column) index on a table in an RDBMS that just performs a quick look-up. So this theoretically should be pretty quick. The major advantage of the architecture is, however, that it is designed for high traffic. No locking occurs is the storage module (MVCC and all that) allowing any number of parallel readers as well as serialized writes. With replication, you can even set up multiple machines for a horizontal scale-out and data partitioning (in the future) will let you cope with huge volumes of data. (See [http://jan.prima.de/~jan/plok/archives/72-Some-Context.html slide 13 of Jan Lehnardt's essay] for more on the storage module or the whole post for detailed info in general). == Why Does CouchDB Not Use Mnesia? == Several reasons: * The first is a storage limitation of 2 gig per file. * The second is that it requires a validation and fixup cycle after a crash or power failure, so even if the size limitation is lifted, the fixup time on large files is prohibitive. * Mnesia replication is suitable for clustering, but not disconnected, distributed edits. Most of the "cool" features of Mnesia aren't really useful for CouchDB. * Also Mnesia isn't really a general-purpose, large scale database. It works best as a configuration type database, the type where the data isn't central to the function of the application, but is necessary for the normal operation of it. Think things like network routers, HTTP proxies and LDAP directories, things that need to be updated, configured and reconfigured often, but that configuration data is rarely very large. From couchdb-commits-returnrachel17@example.net Wed Mar 26 20:34:11 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 43280 invoked from network); 26 Mar 2008 20:34:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 20:34:10 -0000 Received: (qmail 4687 invoked by uid 500); 26 Mar 2008 20:34:09 -0000 Delivered-To: rachel17@example.net Received: (qmail 4646 invoked by uid 500); 26 Mar 2008 20:34:09 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 4637 invoked by uid 99); 26 Mar 2008 20:34:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 13:34:09 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 20:33:38 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 1B2C6D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 20:33:50 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 20:33:49 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Trivial Update of "QuickOverview" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/QuickOverview ------------------------------------------------------------------------------ - = Quick Overview = - A quick overview to CouchDB, it's philosophy, architecture, strengths and weaknesses. == What CouchDB is == From couchdb-commits-returnrachel17@example.net Wed Mar 26 20:34:29 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 43360 invoked from network); 26 Mar 2008 20:34:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 20:34:28 -0000 Received: (qmail 4806 invoked by uid 500); 26 Mar 2008 20:34:26 -0000 Delivered-To: rachel17@example.net Received: (qmail 4786 invoked by uid 500); 26 Mar 2008 20:34:26 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 4777 invoked by uid 99); 26 Mar 2008 20:34:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 13:34:26 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 20:33:55 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id A6047D2E9 for <rachel17@example.net>; Wed, 26 Mar 2008 20:34:06 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 20:34:06 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Trivial Update of "Faq" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/Faq ------------------------------------------------------------------------------ - = FAQ = - A handy FAQ for all your CouchDB related questions. If you have a question not yet answered in this FAQ please hit the edit button and add your question at the end. Check back in a few days, someone may have provided an answer. From couchdb-commits-returnrachel17@example.net Wed Mar 26 20:43:38 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 47110 invoked from network); 26 Mar 2008 20:43:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 20:43:38 -0000 Received: (qmail 18969 invoked by uid 500); 26 Mar 2008 20:43:37 -0000 Delivered-To: rachel17@example.net Received: (qmail 18937 invoked by uid 500); 26 Mar 2008 20:43:37 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 18928 invoked by uid 99); 26 Mar 2008 20:43:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 13:43:37 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 20:42:43 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 2C98CD2DD for <rachel17@example.net>; Wed, 26 Mar 2008 20:43:03 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 20:43:03 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "TechnicalOverview" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/TechnicalOverview The comment on the change is: Copied from original CouchDB wiki New page: A technical overview of the CouchDB document-oriented database system. This overview is intended to give a high-level introduction of key models and components of CouchDB, how they work individually and how they fit together. == Storage == A CouchDB server hosts named databases, which store documents. Each document is uniquely named in the database, and CouchDB provides a [http://en.wikipedia.org/wiki/REST RESTful] HTTP API for reading and updating (add, edit, delete) database documents. Documents are the primary unit of data in CouchDB and consist of any number of fields and binary blobs. Documents also include metadata that's maintained by the database system. Document fields are uniquely named and contain an ordered list of elements. Elements can be of varying types (text, number, date, time), and there is no set limit to text size or element count. Binary blobs also are uniquely named. The CouchDB document update model is lockless and optimistic. Document edits are made by client applications loading documents, applying changes, and saving them back to the database. If another client editing the same document saves their changes first, the client gets an edit conflict error on save. To resolve the update conflict, the latest document version can be opened, the edits reapplied and the update tried again. Document updates (add, edit, delete) are all or nothing, either succeeding entirely or failing completely. The database never contains partially saved or edited documents. === ACID Properties === The CouchDB file layout and commitment system features all Atomic Consistent Isolated Durable (ACID) properties. On-disk, CouchDB never overwrites committed data or associated structures, ensuring the database file is always in a consistent state. This is a "crash-only" design where the CouchDB server does not go through a shut down process, it's simply terminated. Document updates (add, edit, delete) are serialized, except for binary blobs which are written concurrently. Database readers are never locked out and never have to wait on writers or other readers. Any number of clients can be reading documents without being locked out or interrupted by concurrent updates, even on the same document. CouchDB read operations use a Multi-Version Concurrency Control ([http://en.wikipedia.org/wiki/Multiversion_concurrency_control MVCC]) model where each client sees a consistent snapshot of the database from the beginning to the end of the read operation. Documents are indexed in b-trees by their name (DocID) and a Sequence ID. Each update to a database instance generates a new sequential number. Sequence IDs are used later for incrementally finding changes in a database. Theses b-tree indexes are updated simultaneously when documents are saved or deleted. The index updates always occur at the end of the file (append-only updates). Documents have the advantage of data being already conveniently packaged for storage rather than split out across numerous tables and rows in most databases systems. When documents are committed to disk, the document fields and metadata are packed into buffers, sequentially one document after another (helpful later for efficient building of views). When CouchDB documents are updated, all data and associated indexes are flushed to disk and the transactional commit always leaves the database in a completely consistent state. Commits occur in two steps: 1. All document data and associated index updates are synchronously flushed to disk. 2. The updated database header is written in two consecutive, identical chunks to make up the first 4k of the file, and then synchronously flushed to disk. In the event of an OS crash or power failure during step 1, the partially flushed updates are simply forgotten on restart. If such a crash happens during step 2 (committing the header), a surviving copy of the previous identical headers will remain, ensuring coherency of all previously committed data. Excepting the header area, consistency checks or fix-ups after a crash or a power failure are never necessary. === Compaction === Wasted space is recovered by occasional compaction. On schedule, or when the database file exceeds a certain amount of wasted space, the compaction process clones all the active data to a new file and then discards the old file. The database remains completely online the entire time and all updates and reads are allowed to complete successfully. The old file is deleted only when all the data has been copied and all users transitioned to the new file. == Views == ACID properties only deal with storage and updates, we also need the ability to show our data in interesting and useful ways. Unlike SQL databases where data must be carefully decomposed into tables, data in CouchDB is stored in semi-structured documents. CouchDB documents are flexible and each has its own implicit structure, which alleviates the most difficult problems and pitfalls of bi-directionally replicating table schemas and their contained data. But beyond acting as a fancy file server, a simple document model for data storage and sharing is too simple to build real applications on - it simply doesn't do enough of the things we want and expect. We want to slice and dice and see our data in many different ways. What is needed is a way to filter, organize and report on data that hasn't already been decomposed into tables. === View model === To address this problem of adding structure back to unstructured and semi-structured data, CouchDB integrates a view model. Views are the method of aggregating and reporting on the documents in a database, and are built on-demand to aggregate, join and report on database documents. Views are built dynamically and don't affect the underlying document, you can have as many different view representations of the same data as you like. View definitions are strictly virtual and only display the documents from the current database instance, making them separate from the data they display and compatible with replication. CouchDB views are defined inside special "design" documents and can replicate across database instances like regular documents, so that not only data replicates in CouchDB, but entire application designs replicate too. === Javascript View Functions === Views are defined using Javascript functions acting as the map part in a [http://en.wikipedia.org/wiki/MapReduce map-reduce system]. A view function takes a CouchDB document as an argument and then does whatever computation it needs to do to determine if it should be in the view or not. The function simply returns the document or a subset of its data if it should be in the View or nothing if not. === View Indexes === Views are a dynamic representation of the actual document contents of a database, and CouchDB makes it easy to create useful views of data. But generating a view of a database with hundreds of thousands or millions of documents is time and resource consuming, it's not something the system should do from scratch each time. To keep view querying fast, the view engine maintains cached indexes of its views, and incrementally updates them to reflect changes in the database. CouchDB's core design is largely optimized around the need for efficient, incremental creation of views and their indexes. Views and their functions are defined inside special "design" documents, and a design document may contain any number of uniquely named view formulas. When a user opens a view and its index is automatically updated, all the views in the same design document are indexed as a single group. The view builder uses the database Sequence ID to determine if the view group is fully up-to-date with the database. If not, the view engine examines the all database documents (in packed sequential order) changed since the last refresh. Documents are read in the order they occur in the disk file, reducing the frequency and cost of disk head seeks. The views can be read and queried simultaneously while being also being refreshed. If a client is slowly streaming out the contents of a large view, the same view can be concurrently opened and refreshed for another client without blocking the first client. This is true for any number of simultaneous client readers, who can read and query the view while the index is concurrently being refreshed for other clients without causing problems for the readers. As documents are examined, their previous row values are removed from the view indexes, if they exist. If the document is selected by a view function, the function results are inserted into the view as a new row. When view index changes are written to disk, the updates are always appended at the end of the file, serving to both reduce disk head seek times during disk commits and to ensure crashes and power failures can not cause corruption of indexes. If a crash occurs while updating a view index, the incomplete index updates are simply lost and rebuilt incrementally from its previously committed state. == Security and Validation == To protect who can read and update documents, CouchDB has a simple reader access and update validation model that can be extended to implement custom security models. === Administrator Access === CouchDB database instances have administrator accounts. Administrator accounts can create other administrator accounts and update design documents. Design documents are special documents containing view definitions and other special formulas, as well as regular fields and blobs. === Reader Access === To protect document contents, CouchDB documents can have a reader list. This is an optional list of reader-names allowed to read the document. When a reader list is used, protected documents are only viewable by listed users. When a user accesses a database, the his/her credentials (name and password) are used to dynamically determine his reader names. The user credentials are input to a javascript function and the function returns a list of names for the user, or an error if the user credentials are wrong. When a document is protected by reader access lists, any user attempting to read the document must be listed. Reader lists are enforced in views too. Documents that are not allowed to be read by the user are dynamically filtered out of views, keeping the document row and extracted information invisible to non-readers. === Update Validation === As documents written to disk, they can be validated dynamically by javascript functions for both security and data validation. When the document passes all the formula validation criteria, the update is allowed to continue. If the validation fails, the update is aborted and the user client gets an error response. Both the user's credentials and the updated document are given as inputs to the validation formula, and can be used to implement custom security models by validating a user's permissions to update a document. A basic "author only" update document model is trivial to implement, where document updates are validated to check if the user is listed in an "author" field in the existing document. More dynamic models are also possible, like checking a separate user account profile for permission settings. The update validations are enforced for both live usage and replicated updates, ensuring security and data validation in a shared, distributed system. == Distributed Updates and Replication == CouchDB is a peer-based distributed database system, it allows for users and servers to access and update the same shared data while disconnected and then bi-directionally replicate those changes later. The CouchDB document storage, view and security models are designed to work together to make true bi-directional replication efficient and reliable. Both documents and designs can replicate, allowing full database applications (including application design, logic and data) to be replicated to laptops for offline use, or replicated to servers in remote offices where slow or unreliable connections make sharing data difficult. The replication process is incremental. At the database level, replication only examines documents updated since the last replication. Then for each updated document, only fields and blobs that have changed are replicated across the network. If replication fails at any step, due to network problems or crash for example, the next replication restarts at the same document where it left off. Partial replicas can be created and maintained. Replication can be filtered by a javascript function, so that only particular documents or those meeting specific criteria are replicated. This can allow users to take subsets of a large shared database application offline for their own use, while maintaining normal interaction with the application and that subset of data. === Conflicts === Conflict detection and management are key issues for any distributed edit system. The CouchDB storage system treats edit conflicts as a common state, not an exceptional one. The conflict handling model is simple and "non-destructive" while preserving single document semantics and allowing for decentralized conflict resolution. CouchDB allows for any number of conflicting documents to exist simultaneously in the database, with each database instance deterministically deciding which document is the "winner" and which are conflicts. Only the winning document can appear in views, while "losing" conflicts are still accessible and remain in the database until deleted or purged during database compaction. Because conflict documents are still regular documents, they replicate just like regular documents and are subject to the same security and validation rules. When distributed edit conflicts occur, every database replica sees the same winning revision and each has the opportunity to resolve the conflict. Resolving conflicts can be done manually or, depending on the nature of the data and the conflict, by automated agents. The system makes decentralized conflict resolution possible while maintaining single document database semantics. The following view function indexes all documents with conflicts, which can be helpful for automated resolution: {{{ function(doc) { if(doc.conflicts) { map(null, doc); }} }}} Conflict management continues to work even if multiple disconnected users or agents attempt to resolve the same conflicts. If resolved conflicts result in more conflicts, the system accommodates them in the same manner, determining the same winner on each machine and maintaining single document semantics. === Applications === Using just the basic replication model, many traditionally single server database applications can be made distributed with almost no extra work. CouchDB replication is designed to be immediately useful for basic database applications, while also being extendable for more elaborate and full-featured uses. With very little database work, it is possible to build a distributed document management application with granular security and full revision histories. Updates to documents can be implemented to exploit incremental field and blob replication, where replicated updates are nearly as efficient and incremental as the actual edit differences ("diffs"). The CouchDB replication model can be modified for other distributed update models. If the storage engine is enhanced to allow multi-document update transactions, it is possible to perform Subversion-like "all or nothing" atomic commits when replicating with an upstream server, such that any single document conflict or validation failure will cause the entire update to fail. Like Subversion, conflicts would be resolved by doing a "pull" replication to force the conflicts locally, then merging and re-replicating to the upstream server. == Implementation == CouchDB is built on the [http://www.erlang.org/ Erlang OTP platform], a functional, concurrent programming language and development platform. Erlang was developed for real-time telecom applications with an extreme emphasis on reliability and availability. Both in syntax and semantics, Erlang is very different from conventional programming languages like C or Java. Erlang uses lightweight "processes" and message passing for concurrency, it has no shared state threading and all data is immutable. The robust, concurrent nature of Erlang is ideal for a database server. CouchDB is designed for lock-free concurrency, in the conceptual model and the actual Erlang implementation. Reducing bottlenecks and avoiding locks keeps the entire system working predictably under heavy loads. CouchDB can accommodate many clients replicating changes, opening and updating documents, and querying views whose indexes are simultaneously being refreshed for other clients, without needing locks. For higher availability and more concurrent users, CouchDB is designed for "shared nothing" clustering. In a "shared nothing" cluster, each machine is independent and replicates data with its cluster mates, allowing individual server failures with zero downtime. And because consistency scans and fix-ups aren't needed on restart, if the entire cluster fails – due to a power outage in a datacenter, for example – the entire CouchDB distributed system becomes immediately available after a restart. CouchDB is built from the start with a consistent vision of a distributed document database system. Unlike cumbersome attempts to bolt distributed features on top of the same legacy models and databases, it is the result of careful ground-up design, engineering and integration. The document, view, security and replication models, the special purpose query language, the efficient and robust disk layout and the concurrent and reliable nature of the Erlang platform are all carefully integrated for a reliable and efficient system. From couchdb-commits-returnrachel17@example.net Wed Mar 26 20:56:59 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 52640 invoked from network); 26 Mar 2008 20:56:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 20:56:58 -0000 Received: (qmail 36500 invoked by uid 500); 26 Mar 2008 20:56:58 -0000 Delivered-To: rachel17@example.net Received: (qmail 36470 invoked by uid 500); 26 Mar 2008 20:56:58 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 36461 invoked by uid 99); 26 Mar 2008 20:56:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 13:56:58 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 20:56:15 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 3B309D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 20:56:27 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 20:56:27 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "Troubleshooting" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/Troubleshooting The comment on the change is: Copied from original CouchDB wiki New page: A step by step troubleshooting guide for CouchDB. == Updated Source == Have you built CouchDB from the Subversion repository? Did you do a ''svn up'' that seemed to break everything? After every update you must run the following command: {{{ ./bootstrap -C }}} If you still have problems building try the next troubleshooting tip. == First Run == Having problems getting CouchDB to run for the first time? Follow this simple procedure and report back to mailing list (or IRC) with the output of each step. 1. Note down the name of your operating system and your processor architecture. 2. Note down the installed versions of CouchDB's dependancies 3. Checkout a fresh version from Subversion {{{ svn checkout http://couchdb.googlecode.com/svn/trunk/ couchdb }}} 4. Bootstrap from the couchdb directory {{{ ./bootstrap -C }}} 5. Build into a temporary directory {{{ ./configure --prefix=/tmp/couchdb && make && make install }}} 6. Run the ''couchdb'' command and log the output {{{ /tmp/couchdb/bin/couchdb }}} 7. Use your system's kernel trace tool and log the output of the above command 1. Linux systems should use strace {{{ strace /tmp/couchdb/bin/couchdb 2> strace.out }}} 2. Please add documentation for ''your'' system... 8. Report back to the mailing list (or IRC) with the output from each step. From couchdb-commits-returnrachel17@example.net Wed Mar 26 21:02:25 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 56066 invoked from network); 26 Mar 2008 21:02:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 21:02:25 -0000 Received: (qmail 46431 invoked by uid 500); 26 Mar 2008 21:02:23 -0000 Delivered-To: rachel17@example.net Received: (qmail 46408 invoked by uid 500); 26 Mar 2008 21:02:23 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 46399 invoked by uid 99); 26 Mar 2008 21:02:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 14:02:23 -0700 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 21:01:41 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 85CA0D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 21:02:01 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 21:02:01 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "GettingStartedFuton" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/GettingStartedFuton The comment on the change is: Copied from original CouchDB wiki New page: Getting started with Futon, CouchDB's Web administration console. CouchDB comes with a built in web front end which can be accessed by your browser by simply navigating to: http://example.com:5984/_utils/ >>From there you can create or delete databases and manage individual couchdb documents (analogous to records). Among the other utilities are a !JavaScript shell, a replicator GUI and a test suite. From couchdb-commits-returnrachel17@example.net Wed Mar 26 22:24:34 2008 Return-Path: <couchdb-commits-returnrachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 2058 invoked from network); 26 Mar 2008 22:24:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 22:24:31 -0000 Received: (qmail 72563 invoked by uid 500); 26 Mar 2008 22:24:30 -0000 Delivered-To: rachel17@example.net Received: (qmail 72542 invoked by uid 500); 26 Mar 2008 22:24:30 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 72533 invoked by uid 99); 26 Mar 2008 22:24:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 15:24:30 -0700 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 22:23:47 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 4E0DBD2DD for <rachel17@example.net>; Wed, 26 Mar 2008 22:23:59 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 22:23:59 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "GettingStartedAmazon" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/GettingStartedAmazon The comment on the change is: Copied from the original CouchDB wiki New page: Getting started with CouchDB and the Amazon Elastic Compute Cloud. == Quickstart == * Run AMI ''ami-b832d7d1'', get Public DNS. * Authorize TCP port 5984. * In browser open http://PublicDNS.compute-1.amazonaws.com:5984/. == Detailed Description == This AMI release has base Debian 3.1 (Etch) with Elastic Drive installation, so you might consider some kind of persistence to Amazon S3 or other supported platforms, like Nirvanix etc., thus preserving the data that is stored in CouchDB. CouchDB has been built from source (version 0.7.2, revision 645), and configured to run as a service. == AMI Support == All the necessary information has been submitted for inclusion into repository of Amazon Public AMIs, and is listed as [http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1192&categoryID=101 ElasticDB - (Elasticdrive + CouchDB)]. We created support thread at Amazon forums, specifically [http://developer.amazonwebservices.com/connect/thread.jspa?threadID=19405&tstart=0 Amazon SimpleDB (Beta)] and provide limited support there, when time allows and scope is limited to EC2/SimpleDB-related issues. If you have couchDB internals related question, it is better addressed by respective community. == Future Work == [http://ihatecubicle.blogspot.com/ Khaz Sapenov] is planning to test SMP features of CouchDB on extra-large instances and to see how it all works out for Erlang. From couchdb-commits-return-rachel17@example.net Wed Mar 26 22:28:15 2008 Return-Path: <couchdb-commits-return-rachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 3363 invoked from network); 26 Mar 2008 22:28:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 22:28:15 -0000 Received: (qmail 74769 invoked by uid 500); 26 Mar 2008 22:28:14 -0000 Delivered-To: rachel17@example.net Received: (qmail 74736 invoked by uid 500); 26 Mar 2008 22:28:14 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 74727 invoked by uid 99); 26 Mar 2008 22:28:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 15:28:14 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 22:27:42 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 8D737D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 22:27:54 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 22:27:54 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "GettingStartedErlang" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/GettingStartedErlang The comment on the change is: Copied from the original CouchDB wiki New page: Getting started with Erlang and the CouchDB API. It is quite easy to throw together a quick interface to CouchDB in Erlang using inets or ibrowse because CouchDB API is so easy. On such interface currently exists at: http://code.google.com/p/erlcouch/ Documentation can be found as part of the library. From couchdb-commits-return-rachel17@example.net Wed Mar 26 22:35:19 2008 Return-Path: <couchdb-commits-return-rachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 5653 invoked from network); 26 Mar 2008 22:35:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 22:35:17 -0000 Received: (qmail 82435 invoked by uid 500); 26 Mar 2008 22:35:16 -0000 Delivered-To: rachel17@example.net Received: (qmail 82409 invoked by uid 500); 26 Mar 2008 22:35:16 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 82400 invoked by uid 99); 26 Mar 2008 22:35:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 15:35:16 -0700 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 22:34:45 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id B4A65D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 22:34:56 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 22:34:56 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Trivial Update of "GettingStartedFuton" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/GettingStartedFuton ------------------------------------------------------------------------------ CouchDB comes with a built in web front end which can be accessed by your browser by simply navigating to: - http://example.com:5984/_utils/ + http://example.com:5984/_utils/ From there you can create or delete databases and manage individual couchdb documents (analogous to records). From couchdb-commits-return-rachel17@example.net Wed Mar 26 22:38:40 2008 Return-Path: <couchdb-commits-return-rachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 6442 invoked from network); 26 Mar 2008 22:38:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 22:38:40 -0000 Received: (qmail 88808 invoked by uid 500); 26 Mar 2008 22:38:39 -0000 Delivered-To: rachel17@example.net Received: (qmail 88782 invoked by uid 500); 26 Mar 2008 22:38:39 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 88767 invoked by uid 99); 26 Mar 2008 22:38:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 15:38:39 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 22:38:07 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 19D37D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 22:38:19 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 22:38:18 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "GettingStartedLotusScript" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/GettingStartedLotusScript The comment on the change is: Copied from the original CouchDB wiki New page: Getting started with !LotusScript and the CouchDB API. This is an example of wrapper classes that use LS2J to send requests to a !CouchDB server from !LotusScript. This could be useful to move data between Domino databases and !CouchDB databases. The !LotusScript code roughly tracks the structure of the Ruby code. A more comprehensive ["Lotuscript API"] is in progress. == LS2CouchDb == {{{ Option Public Uselsx "*javacon" }}} {{{ Sub Initialize %REM LotusScript LS2J classes for CouchDb Copyright (C) 2006 Alan Bell - Dominux Consulting This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %ENDREM 'right now this just implements the basic database operations 'feel free to fix bugs and add functionailty to it in the Wiki 'there is a total lack of releasing of objects right now so it will leak memory like a sieve 'error handling would be nice too. Dim cserver As couchserver Set cserver=New couchserver("http://localhost","5984","") 'create a database Call cserver.put("/ls2couch/","") 'create a document Call cserver.put("/ls2couch/document_id", |{"type":"comment","body":"First Post!"}|) 'retrieve the document Print cserver.cget("/ls2couch/document_id") 'delete the database Call cserver.del("/ls2couch/") End Sub }}} {{{ Class couchserver Private host As String Private port As String Private options As String Private proxyserver As String Private proxyport As String Private jses As JAVASESSION Private jclass As JAVACLASS Private jurl As JAVAOBJECT Private jcon As JAVAOBJECT Sub new(host As String,port As String,options As String) 'this corresponds to the initialise method in the Ruby classes Me.host=host Me.port=port Me.options=options Set Me.jses=New JAVASESSION() End Sub Sub setproxy(proxyserver As String,proxyport As String) 'this should do something. At the moment it does not. Me.proxyserver=proxyserver Me.proxyport=proxyport End Sub Sub del(uri As String) 'this corresponds to the delete method in the Ruby classes Set Me.jclass=jses.GetClass("java/net/URL") Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri) Set jcon=jurl.openConnection() Me.jcon.setRequestMethod("DELETE") Call Me.jcon.connect() Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it. Call ist.close() End Sub Function cget(uri As String) As String 'this corresponds to the get class in Ruby. "get" is a reserved word Set Me.jclass=jses.GetClass("java/net/URL") Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri) Set jcon=jurl.openConnection() Me.jcon.setRequestMethod("GET") Call Me.jcon.connect() Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it. Set Me.jclass=jses.GetClass("java/io/InputStreamReader") Set ireader=Me.jclass.CreateObject("(Ljava/io/InputStream;)V",ist) Set Me.jclass=jses.GetClass("java/io/BufferedReader") Set bReader=Me.jclass.CreateObject("(Ljava/io/Reader;)V",ireader) cget=bReader.readLine() Call ist.close() End Function Sub put (uri As String,xml As String) Set Me.jclass=jses.GetClass("java/net/URL") Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri) Set jcon=jurl.openConnection() Me.jcon.setRequestMethod("PUT") Me.jcon.setdooutput(True) Call Me.jcon.connect() Set ost=jcon.getOutputStream() Set Me.jclass=jses.GetClass("java/io/OutputStreamWriter") Set owriter=Me.jclass.CreateObject("(Ljava/io/OutputStream;)V",ost) Call owriter.write(xml,0,Len(xml)) Call owriter.flush() Call ost.write(32) Call ost.flush() Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it. Call ist.close() End Sub Sub post(uri As String,xml As String) Set Me.jclass=jses.GetClass("java/net/URL") Set Me.jurl=Me.jclass.CreateObject("(Ljava/lang/String;)V",host+":"+port+uri) Set jcon=jurl.openConnection() Me.jcon.setRequestMethod("PUT") Me.jcon.setdooutput(True) Call Me.jcon.connect() Set ost=jcon.getOutputStream() Call ost.write(32) Call ost.flush() Set ist=jcon.getInputStream()'oddly enough java doesn't do anything with a URL until you read from it. Call ist.close() End Sub End Class }}} From couchdb-commits-return-rachel17@example.net Wed Mar 26 22:39:18 2008 Return-Path: <couchdb-commits-return-rachel17@example.net> Delivered-To: rachel17@example.net Received: (qmail 6497 invoked from network); 26 Mar 2008 22:39:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 26 Mar 2008 22:39:18 -0000 Received: (qmail 88945 invoked by uid 500); 26 Mar 2008 22:39:17 -0000 Delivered-To: rachel17@example.net Received: (qmail 88929 invoked by uid 500); 26 Mar 2008 22:39:17 -0000 Mailing-List: contact rachel17@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:rachel17@example.net> List-Unsubscribe: <mailto:rachel17@example.net> List-Post: <mailto:rachel17@example.net> List-Id: <couchdb-commits.incubator.apache.org> Reply-To: rachel17@example.net Delivered-To: mailing list rachel17@example.net Received: (qmail 88920 invoked by uid 99); 26 Mar 2008 22:39:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 15:39:17 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eos.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Mar 2008 22:38:35 +0000 Received: from eos.apache.org (localhost [83.161.120.155]) by eos.apache.org (Postfix) with ESMTP id 4A324D2DD for <rachel17@example.net>; Wed, 26 Mar 2008 22:38:55 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki <rachel17@example.net> To: rachel17@example.net Date: Wed, 26 Mar 2008 22:38:55 -0000 Message-ID: <rachel17@example.net> Subject: [Couchdb Wiki] Update of "Getting Started With LotusScript" by NoahSlater X-Virus-Checked: Checked by ClamAV on apache.org 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 NoahSlater: http://wiki.apache.org/couchdb/Getting_Started_With_LotusScript ------------------------------------------------------------------------------ + ## page was renamed from GettingStartedLotusScript Getting started with !LotusScript and the CouchDB API. This is an example of wrapper classes that use LS2J to send requests to a !CouchDB server from !LotusScript. This could be useful to
{'source': 'Apache Software Foundation Public Mail Archives'}