This part (Part II, “Developing with CouchDB”, Chapters Chapter 5, Design Documents through Chapter 9, Transforming Views with List Functions) lays the foundation for Part III, “Example Application”, where we take what we’ve learned and build a small blog application to further develop an understanding of how CouchDB applications are built. The application is called Sofa, and on a few occasions we discuss it in this part. If you are unclear on what we are referring to, do not worry, we’ll get to it in Part III, “Example Application”.
This article provides a simple example of using delegates and events to transfer data between Windows forms. The example provided contains three separate forms; the main form interacts with the other two forms by responding to events generated by instances of the other two forms.
In order to communicate between the forms, each of forms capable of generating an event contains declarations for a delegate and an event. A delegate may be thought of as a type safe function pointer and delegates are associated with methods that bear the same signature. An event is a device used to notify listening objects that something has happened; events are associated with a delegate when instantiated.
Through the use of delegates and events it is possible to communicate values between forms in a Win Forms application.
Figure 1. Using Delegates and Events to Communicate Between Forms
Installing from Source
Generally speaking, you should avoid installing from source. Many operating systems provide package managers that will allow you to download and install CouchDB with a single command. These package managers usually take care of setting things up correctly, handling security, and making sure that the CouchDB database is started and stopped correctly by your system. The first few appendixes showed you how to install CouchDB packages for Unix-like, Mac OS X, and Windows operating systems. If you are unable to follow those instructions, or you need to install by hand for other reasons, this chapter is for you.
To build and install CouchDB, you will need to install a collection of other software that CouchDB depends on. Without this software properly installed on your system, CouchDB will refuse to work. You’ll need to download and install the following:
It is recommended that you install Erlang OTP R12B-5 or above if possible.
Each of these software packages should provide custom installation instructions, either on the website or in the archive you download. If you’re lucky, however, you may be able to use a package manager to install these dependencies.
CouchDB 1.0.x crashes on Windows when a database or index file reaches 4Gb in Erlang/OTP versions previous to R14B01. This is due to a Erlang/OTP Windows bug related with appending to files with a size equal to 4Gb or larger. Erlang/OTP release R14B01 no longer has this bug.
This page describes how to build and install couchdb from source on Windows. See also the Windows_binary_installer.
There is a Windows binary installer in “beta testing”. See the wiki page for it for more instructions.
Other source of installers for Windows, including future CouchDB releases, are at
Building current couchdb versions
As of couchdb 0.10, support for Windows is included in the standard build process. View README in the root of the source tree for information about the dependencies and how to configure the build process. In summary, you will need to:
- Install the cygwin environment.
- Install the MS C compiler.
- Install and possibly build a number of pre-requisites, such as curl, icu, spidermonkey, etc.
- get the sources to erlang and couch
- configure and build erlang according to the instructions.
- configure and build couch according to the README file in couch
After executing ‘make install’, you will find a couchdb directory structure inside your erlang directory – that is, the couch build process simply installs its libraries into the erlang binaries you previously build. This directory structure should be ready to roll – it can be zipped up, packaged by an installer, etc.
In this chapter, we’ll take a quick tour of CouchDB’s features, familiarizing ourselves with Futon, the built-in administration interface. We’ll create our first document and experiment with CouchDB views. Before we start, skip to Appendix D, Installing from Source and look for your operating system. You will need to follow those instructions and get CouchDB installed before you can progress.
All Systems Are Go!
We’ll have a very quick look at CouchDB’s bare-bones Application Programming Interface (API) by using the command-line utility
curl. Please note that this is not the only way of talking to CouchDB. We will show you plenty more throughout the rest of the book. What’s interesting about
curl is that it gives you control over raw HTTP requests, and you can see exactly what is going on “underneath the hood” of your database.
What is CouchDB?
CouchDB can be installed on most POSIX systems, including Linux® and Mac OS X. Although Windows® isn’t currently officially supported, work is under way on an unofficial binary installer for the Windows platform. CouchDB can be installed from source or, where available, it can be installed using a package manager (e.g., MacPorts on Mac OS X).
CouchDB is a top-level Apache Software Foundation open source project, released under V2.0 of the Apache license. This open source license allows the source code to be used and modified for use in other software, so long as the copyright notice and disclaimer are preserved. Like most open source licenses, it allows the software to be used, modified, and distributed by users as required. Any modifications do not have to be made available under the same license, so long as a notice of use of Apache-licensed code is maintained.