# couchdb-query-helper

> Module to help query couchDB in NodeJs applications

Latest version **1.1.6** (published 2019-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install couchdb-query-helper
pnpm add couchdb-query-helper
yarn add couchdb-query-helper
bun add couchdb-query-helper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2019-09-27 |
| First published | 2019-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Raj Kumar |
| Maintainers | sasuke_uchiha |
| Keywords | couchdb, node, query, query builder, schema builder, database manager |

## Links

- npm: https://www.npmjs.com/package/couchdb-query-helper
- Repository: https://github.com/rajcrk/couchdb-query-helper
- Issues: https://github.com/rajcrk/couchdb-query-helper/issues
- npm.io page: https://npm.io/package/couchdb-query-helper

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.19.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.6 (latest) — 2019-09-27
- 1.1.5 — 2019-09-27
- 1.1.4 — 2019-09-25
- 1.1.3 — 2019-09-21
- 1.1.2 — 2019-09-20
- 1.1.1 — 2019-09-20
- 1.1.0 — 2019-09-20
- 1.0.0 — 2019-09-20

## README

# couchdb-query-helper
[![npm version](https://img.shields.io/badge/npm-v1.1.2-green)](https://npmjs.org/package/couchdb-query-helper)
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
```sh
npm i couchdb-query-helper
```
## How to use
### Initializing the library
couchdb-query-helper module is itself a function which takes a configuration object.
```js
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
```js
queryHelper
    .query()
    .selectAll(tableName)
    .then((responseData) => console.log(responseData))
    .catch((err) => console.log(err));
```
#### Retrieving All Databases available
```js
queryHelper
    .db()
    .showDatabases()
    .then((responseData) => console.log(responseData))
    .catch((err) => console.log(err));
```
#### Inserting a document
```js
queryHelper
    .query()
    .insert(documentId, documentData, databaseName)
    .then((responseData) => console.log(responseData)) 
    .catch((err) => console.log(err));
```
#### Deleting a document
```js
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.

```js
 queryHelper
    .query()
    .select(array_of_key, array_of_values, databaseName)
    .then((responseData) => console.log(responseData)) 
    .catch((err) => console.log(err));
```

#### Creating a new database
```js
    queryHelper
        .db()
        .createDatabase(dbName)
        .then((responseData) => console.log(responseData)) 
        .catch((err) => console.log(err));
```
#### Drop a database
```js
    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

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

---
_Source: https://npm.io/package/couchdb-query-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
