nhf_db

2.2.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i nhf_db

Weekly Downloads

13

Version

2.2.0

License

none

Last publish

Collaborators

  • 900feet