Last Updated: February 25, 2016
· dscape

Nano - CouchDB Client for Node.js

If you need a CouchDB client for #nodejs you should try nano!


var nano = require('nano')('http://localhost:5984');

// clean up the database we created previously
nano.db.destroy('alice', function() {
  // create a new database
  nano.db.create('alice', function() {
    // specify the database we are going to use
    var alice = nano.use('alice');
    // and insert a document in it
    alice.insert({ crazy: true }, 'rabbit', function(err, body, header) {
      if (err) {
        console.log('[alice.insert] ', err.message);
      console.log('you have inserted the rabbit.')

2 Responses
Add your response


hi, Im new on this but how can I execute this code? if i call the .js file from a html this send me an error from require, i have nano installed.

over 1 year ago ·

@gearcesar - nano is a library for node.js, so you should not try to call it from an HTML page in a browser.

over 1 year ago ·