Socket
Socket
Sign inDemoInstall

couchdb-query-helper

Package Overview
Dependencies
4
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    couchdb-query-helper

Module to help query couchDB in NodeJs applications


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

couchdb-query-helper

npm version A module to help query couch DB in node applications

couchdb-query-helper is a library that can help you build query, schema, and control your database more easier.

Presently can only be used on the NodeJS version 8 or higher.Supports CouchDb version 15.10 or higher.

Installation

npm i couchdb-query-helper

How to use

Initializing the library

couchdb-query-helper module is itself a function which takes a configuration object.

const queryHelper = require('couchdb-query-helper')
  .connection({
    host: 'localhost',
    protocol: 'http://',
    port: '5984',
    user: 'admin',
    pass: 'admin'
  });

Retrieving results

Retrieving All Rows From A Table
queryHelper
    .query()
    .selectAll(tableName)
    .then((responseData) => console.log(responseData))
    .catch((err) => console.log(err));
Retrieving All Databases available
queryHelper
    .db()
    .showDatabases()
    .then((responseData) => console.log(responseData))
    .catch((err) => console.log(err));
Inserting a document
queryHelper
    .query()
    .insert(documentId, documentData, databaseName)
    .then((responseData) => console.log(responseData)) 
    .catch((err) => console.log(err));
Deleting a document
queryHelper
    .query()
    .delete(documentId, databaseName)
    .then((responseData) => console.log(responseData)) 
    .catch((err) => console.log(err));
Select with condition (In Developement)

array_of_key represents the key that you are searching for and array_of_values represents the values that the key should have.

 queryHelper
    .query()
    .select(array_of_key, array_of_values, databaseName)
    .then((responseData) => console.log(responseData)) 
    .catch((err) => console.log(err));
Creating a new database
    queryHelper
        .db()
        .createDatabase(dbName)
        .then((responseData) => console.log(responseData)) 
        .catch((err) => console.log(err));
Drop a database
    queryHelper
        .db()
        .dropDatabase(dbName)
        .then((responseData) => console.log(responseData)) 
        .catch((err) => console.log(err));
Run your regular find with custom queries

You can use the regular JSON object for queries, to know more about the select option visit http://docs.couchdb.org/en/stable/api/database/find.html

    queryHelper
        .query()
        .bareSelect(dbName, selectorSample)
        .then((responseData) => console.log(responseData)) 
        .catch((err) => console.log(err));

Keywords

FAQs

Last updated on 27 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc