# nhf_db

> common database library for 900feet API

Latest version **2.2.0** (published 2015-05-17) · 0 weekly downloads

## Install

```sh
npm install nhf_db
pnpm add nhf_db
yarn add nhf_db
bun add nhf_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 | 2.2.0 |
| Published | 2015-05-17 |
| First published | 2015-05-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Erik Wool |
| Maintainers | 900feet |

## Links

- npm: https://www.npmjs.com/package/nhf_db
- npm.io page: https://npm.io/package/nhf_db

## Dependencies (4)

- [pg](https://npm.io/package/pg.md) ~4.2.0
- [redis](https://npm.io/package/redis.md) ~0.12.1
- [mongojs](https://npm.io/package/mongojs.md) ~0.18.1
- [node-resque](https://npm.io/package/node-resque.md) ~0.12.0

## Recent versions

- 2.2.0 (latest) — 2015-05-17
- 2.1.0 — 2015-05-14
- 2.0.1 — 2015-05-10
- 2.0.0 — 2015-05-10
- 1.1.0 — 2015-05-08
- 1.0.1 — 2015-05-07
- 1.0.0 — 2015-05-06

## README

# 900feet DB Library

This package is intended to create and maintain state for database connections used by 900feet's API. This includes PostgreSQL, Mongo, and Redis connections.

## Connection Functions
* connectPostgres(): instantiate new Postgres client, store in 'postgres'
* connectMongo(): instantiate new Mongo connection for a set of collections, store in 'mongo'
* connectRedis(): instantiate a new redis connection ('redis') and, from that, a new resque connection in 'resqueConnection'
* resqueWorker(): instantiate a new resque worker and execute a callback on instantiation
* resqueQueue(): instantiate a new resque queue and execute a callback on instantiation

## Input checking Functions

* re_quote: regex pattern to check for quotes in a string
* isNumeric(): return true if param is a number
* cleanNumeric(): return true if value is defined, contains no quotes, and is a finite number.  Uses re_quote

## SQL support Functions

* getTimeClause(): returns SQL WHERE clause fragment to constrain by begin/end unix epoch
* getMaptileSQL(): check for location; validate inputs; generate SQL
* executeSQLdel(): executes an SQL delete for ONE record.  ONE!  causes express response json to contain 'ok' or a failure.  DEPRECATED:  REMOVED IN v2
* executeSQLmod(): executes an SQL insert/update/replace/delete for ONE record.  ONE!  causes first element of express response json array to contain 'ok' and id of affected record, or a failure
* buildSaveQuery(): creates an INSERT or UPDATE SQL statement using specified set of fields drawn from record. if id=0, creates INSERT; otherwise creates UPDATE. Automatically adds created_at and updated_at fields set to NOW() as appropriate.
* buildConditionAssignment(): returns SQL WHERE condition from params
* sendSelectedRecords(): accept sql, execute it, and return postgres records

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