1.2.0 • Published 7 years ago

got-couch v1.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Build Status

got-couch

A got based couch driver/interface

NOTE: This driver is very incomplete, however, the goal is to support the all of the CouchDB version 2 features and to cover the entire REST API.

Usage

const GotCouch = require('got-couch')

const CONFIG = {
  url: 'http://localhost'
, port: 5984
, username: 'root'
, password: 'password'
}


const DB_NAME = 'my-test'


GotCouch(CONFIG).then((couchdb) => {

  // create a database
  //http://docs.couchdb.org/en/2.0.0/api/database/common.html#put--db
  couchdb.db.create(DB_NAME).then((response) => { /* ... */ })


  // get information about a database
  // http://docs.couchdb.org/en/2.0.0/api/database/common.html#get--db
  couchdb.db.info(DB_NAME).then((response) => { /* ... */})


  // delete a database
  // http://docs.couchdb.org/en/2.0.0/api/database/common.html#delete--db
  couchdb.db.delete(DB_NAME).then((response) => { /* ... */})


  // insert a document with a generated identifier
  // http://docs.couchdb.org/en/2.0.0/api/database/common.html#post--db
  couchdb.insert(DB_NAME, { test: 'stuff' /* ... */ })

  .then((response) => { /* ... */ })


  // insert a document with a specified identifier (`docid`)
  // http://docs.couchdb.org/en/2.0.0/api/document/common.html#put--db-docid
  couchdb.create(DB_NAME, 'docid', { test: 'stuff' /* ... */ })

  .then((response) => { /* ... */ })


  // retrieve a document by its identifier (`docid`).
  // http://docs.couchdb.org/en/2.0.0/api/document/common.html#get--db-docid
  couchdb.get(DB_NAME, 'docid').then((response) => { /* ... */ })


  // list all the documents in the given database.
  // http://docs.couchdb.org/en/2.0.0/api/database/bulk-api.html#db-all-docs
  couchdb.list(DB_NAME, {}).then((response) => { /* ... */ })


})

Response Object

{
  headers: { /* document headers */ }
, body: { /* body of the stored document */ }
, raw: { /* raw response object from couchdb */ }
}
1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.1

8 years ago

0.0.1

8 years ago