# fh-db

> FeedHenry Database Library

Latest version **3.3.2** (published 2018-10-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install fh-db
pnpm add fh-db
yarn add fh-db
bun add fh-db
```

## 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 | 3.3.2 |
| Published | 2018-10-19 |
| First published | 2013-01-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 4.4 |
| Dependencies | 11 |
| Unpacked size | 198 KB |
| Known vulnerabilities | 0 (+10 in 5 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | akeating-redhat, aliok, david-martin, davidffrench, dbevenius, feedhenry, feedhenry-dev, grdryn, jasonmadigan, luigizuccarelli, matzew, pb82, pbrookes, philipgough, roregan, sedroche, weileylee, wtrocki |

## Links

- npm: https://www.npmjs.com/package/fh-db
- Repository: https://github.com/feedhenry/fh-db
- Homepage: https://github.com/feedhenry/fh-db#readme
- Issues: https://github.com/feedhenry/fh-db/issues
- npm.io page: https://npm.io/package/fh-db

## Dependencies (11)

- [bson](https://npm.io/package/bson.md) 0.4.22
- [jcsv](https://npm.io/package/jcsv.md) 0.0.3
- [async](https://npm.io/package/async.md) 1.5.2
- [lodash](https://npm.io/package/lodash.md) 2.4.1
- [adm-zip](https://npm.io/package/adm-zip.md) 0.4.11
- [env-var](https://npm.io/package/env-var.md) ~2.4.3
- [mongodb](https://npm.io/package/mongodb.md) 2.1.18
- [archiver](https://npm.io/package/archiver.md) 1.0.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.6
- [csvtojson](https://npm.io/package/csvtojson.md) 0.3.6
- [stream-buffers](https://npm.io/package/stream-buffers.md) 3.0.0

## Recent versions

- 3.3.2 (latest) — 2018-10-19
- 3.3.1 — 2018-06-14
- 3.3.0 — 2017-10-27
- 3.2.0 — 2017-10-19
- 3.1.0 — 2017-09-11
- 3.0.0 — 2017-08-29
- 2.1.0 — 2017-07-10
- 2.0.1 — 2017-05-17
- 2.0.0 — 2017-05-02
- 1.4.4 — 2017-03-15
- 1.4.3 — 2017-03-10
- 1.4.1 — 2017-02-02
- 1.2.5 — 2016-11-27
- 1.2.4 — 2016-11-10
- 1.2.3 — 2016-10-03
- … 42 more at https://npm.io/package/fh-db/versions

## README

fh-db(1) -- The FeedHenry Database access library
===============================================

[![npm package](https://nodei.co/npm/fh-db.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/fh-db/)

[![Dependency Status](https://img.shields.io/david/feedhenry/fh-db.svg?style=flat-square)](https://david-dm.org/feedhenry/fh-db)
[![Known Vulnerabilities](https://snyk.io/test/npm/fh-db/badge.svg?style=flat-square)](https://snyk.io/test/npm/fh-db)

|                 | Project Info  |
| --------------- | ------------- |
| License:        | Apache License, Version 2.0  |
| Build:          | npm  |
| Documentation:  | http://docs.feedhenry.com/v3/api/cloud_api.html  |
| Issue tracker:  | https://issues.jboss.org/projects/FH/summary  |
| Mailing list:   | [feedhenry-dev](https://www.redhat.com/archives/feedhenry-dev/) ([subscribe](https://www.redhat.com/mailman/listinfo/feedhenry-dev))  |
| IRC:            | [#feedhenry](https://webchat.freenode.net/?channels=feedhenry) channel in the [freenode](http://freenode.net/) network.  |

## DESCRIPTION

This contains the fh.db() layer the works above the mongodb library. It has a Ditch-like interface, with the same actions and parameters

## Installation

Add fh-db as a dependency to your module and require it where required, like any other npm module

## Testing

**N.B. This guide assumes you have a functional [docker-machine](https://docs.docker.com/machine/install-machine/).**

### Start Mongo Server
Start the docker machine for the version of mongo you wish to test:
```bash
docker run -d -p 27017:27017 mongo:2.6
```

### Note for docker-machine users
You will need to connect your localhost:27017 to the docker-machine:27017, do this with the following command:
```
VBoxManage controlvm `docker-machine active` natpf1 "docker-mongo,tcp,127.0.0.1,27017,,27017"
```
In the above `docker-mongo` is the name of the rule, this is important to remember, in order to remove it when not required.

Remove the above rule as follows:
```
VBoxManage controlvm `docker-machine active` natpf1 delete docker-mongo
```


### Setup Mongo Database
connect to Mongo:
```
mongo
```

#### For MongoDB versions > 3.x
Well, instead of MongoDB 2.6 stated above if you used MongoDB 3.x, you will need to update the authentication
to work with fh-db, which is done as follows:
```
use admin
db.system.users.remove({})
db.system.version.remove({})
db.system.version.insert({ "_id" : "authSchema", "currentVersion" : 3 })
```

Then exit mongo and restart the docker container:
```
docker stop <container-name>
docker start <container-name>
```

And reconnect to mongo:
```
mongo
```

#### Add the admin user:

```
use admin
db.createUser({user: 'admin', pwd: 'admin', roles: ['root']})
```

##### Test the login:
exit mongo and run:
```
mongo admin -u admin -p admin
```

#### Add the ditchuser

Log in as the admin user, if you are not yet, then run:

```
use fh-ditch
db.createUser({user: 'ditchuser', pwd: 'ditchpassword', roles: ['dbAdmin']})
```

##### Test the login:
Exit Mongo and run:
```
mongo fh-ditch -u ditchuser -p ditchpassword
```

### Execute the test
```
grunt fh:unit
```

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