Newtonian Particle Motion

    js-couchdb

    1.1.0 • Public • Published

    couchdb.js

    A Promise based ES6 library that provides an easy way to interact with CouchDB

    Installation

    Via NPM or yarn

    npm install couchdb.js
    
    yarn add couchdb.js
    

    Usage

    v1.1.0: On versions 1.1.0 and higher, all functions are OOP and attached to props on CouchClient. couch.listDatabases() => couch.databases.list(), etc.

    couchdb.js exports a constructor that accepts an object with properties protocol, host and port. These should point to your couchdb server. They default to http, localhost and 3000 respectively.

    // EXAMPLE
    // Server points to localhost:5984
    const { CouchClient } = require('js-couchdb');
     
    // initialize the database
    const db = new CouchDB({
        port: 5984
    });

    NOTE: Databases act like tables, and documents act like keys.

    Creating a database

    db.databases.create('stitch')
        .then(() => console.log('Succesfully created a DB!'));

    Deleting a database

    db.databases.delete('stitch')
        .then(() => console.log('Database deleted!'));

    Creating a document

    // first arg accepts the name of the database
    // second takes in the ID
    // third is the data to store
    db.databases.get('stitch').then(db => db.documents.create('character', {
        disney: true,
        blue: true
    })).then(() => console.log('Added a document!'));

    Getting a document

    database.documents.get('character');

    TODO:

    Better documentation.

    Contribution:

    To contribute to this package, fork the source and create pull requests. Be sure to follow the ESLint rules and code style.

    Keywords

    Install

    npm i js-couchdb

    DownloadsWeekly Downloads

    1

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    15.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • soumil07