Developing an app that depends on a CouchDB doesn’t have to get held up because of the database. Find out why with the help of the Fauxton tool.
If you’re developing an app that depends upon a CouchDB database, the last thing you need is to be held up because you’ve never created a database. Or, if you have any other reason to work with this NoSQL tool, fear not—creating databases is exceptionally easy.
I’m going to introduce you to the task of creating a new CouchDB database, with the help of the built-in Fauxton tool (See: How to install CouchDB on CentOS 7). Using this web-based GUI, you’ll find yourself up to speed in no time.
SEE: Serverless computing: A guide for IT leaders (Tech Pro Research)
What you need
The only thing you need is a running instance of CouchDB and access to the server hosting the database, via a web browser.
Open a web browser and point it to http://SERVER_IP:5984/_utils/ (where SERVER_IP is the IP address of the server hosting CouchDB). You will be prompted for the admin credentials set up during the installation of CouchDB. Once authenticated, you’ll find yourself on the Fauxton main page (Figure A).
Creating a database
CouchDB approaches databases a bit differently. Instead of creating tables, which house multiple entries for the database, you create Documents. Each document holds specific data. For instance, if you have a database called people, you’d create a single document for each person.
Click Create Database and enter a unique name in the popup. You cannot use upper case letters in the name, which you’ll be warned about, should you try. Let’s create a database named people. Once you create the database, you’ll see a Create Document button in the upper right corner (Figure B).
Click Create Document, and you’ll see a text-based editor open, where you can start entering information for the Document (Figure C).
It’s at this point where you might think things get challenging. After all, there is no GUI portion to enter data. Trust me, this is incredibly simple.
Let’s say you want to add an entry for our people database. This entry is in the form of a Document (which you already have open). You can create as many documents as you need for a database. We’ll create a document, which will hold information like:
Of course, you wouldn’t use such a Document when developing a cloud-connected app for public consumption, but this is a good way to illustrate how to enter data in Fauxton.
You’ll already see the new Document has an ID. Do not alter that string of characters, outside of adding a comma to the end, like so:
Once you do that, hit Enter on your keyboard and begin the next line, which will look something like this:
Hit Enter and add the next line like this:
Continue on down, until you create the necessary entries. The last entry (in our example, securitylevel) will not end with a comma (as that indicates the final entry in the document).
Once you complete the document (Figure D), click Create Document to save.
This will take you back to the Create Document window of the database, where you can either click to open and edit the first document or create a new document for the database.
And that’s all there is to creating a CouchDB database, using the Fauxton web-based tool.