
The JavaScript JSON Cookbook
By :

Before you can use a database in CouchDB, you must create it.
Once you've obtained a handle to the database that you want to use, you should check to see whether it exists, and create it if it doesn't:
db.exists(function (err, exists) { if (err) { console.log('error', err); } elseif (!exists) { { db.create(); } });
The exists
method checks to see whether a database exists, calling the callback you provide with an error if one occurred and a flag indicating whether or not the database exists. If the database doesn't exist, you create it using the create
method.
This is a common pattern for Cradle because the RESTful interface is, by nature, asynchronous. You'll pass the arguments to the method you want to perform and a callback function that the method invokes when it's complete.
A common mistake that beginners make is to assume that you can call one of these methods without the callback function and then do...
Change the font size
Change margin width
Change background colour