Skip to content
This repository has been archived by the owner on May 21, 2020. It is now read-only.
/ couchjs Public archive

A light-weight CouchDB nodejs client.

License

Notifications You must be signed in to change notification settings

nephics/couchjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

couchjs

A light-weight CouchDB nodejs client.

Example usage

  var couch = require('./couch.js');

  var db = couch.init('testdb');


  function next(callback) {
   return function(response) {
     if (response.error) {
       console.log('Error: ' + response.reason || response.error);
     }
     else callback(response);
    }
  }

  function start() {
    console.log('Creating db');
    db.createDb(next(insert));
  }
 
  function insert(response) {
    console.log('Saving doc');
    db.saveDoc({'name': 'Test document'}, next(retrieve));
  }

  function retrieve(response) {
    console.log('Retrieving doc ' + response.id);
    db.getDoc(response.id, next(remove));
  }

  function remove(doc) {
    console.log('Got doc with name: ' + doc.name);
    console.log('Removing doc ' + doc._id);
    db.deleteDoc(doc, next(stop));
  }

  function stop(response) {
    console.log('Deleting the db');
    db.deleteDb();
  }

  start();

License

couchjs is is licensed under the terms of the MIT License, see the included MIT-LICENSE file.

About

A light-weight CouchDB nodejs client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published